昨日、Android Studioで昨日このエラーに遭遇しました。これは、触れられていないコード過去3ヶ月これは、プッシュ通知を登録するために使用されているコードから来て、今週初めに細かい仕事をしていたが、今では、このエラーが発生:ここjava.lang.IncompatibleClassChangeErrorに起因する致命的例外を処理するための助けが必要
05-20 10:37:02.064 22471-22681/com.appname E/AndroidRuntime: FATAL EXCEPTION: IntentService[RegIntentService]
Process: com.appname, PID: 22471
java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
at com.google.android.gms.iid.zzd.zzeb(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.appname.services.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:32)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
は私のRegistrationIntentServiceクラスです:
package com.appname.services;
import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.iid.InstanceID;
import com.appname.MainSharedPreferences;
import com.appname.R;
import java.io.IOException;
public class RegistrationIntentService extends IntentService {
private static final String TAG = "RegIntentService";
public RegistrationIntentService() {
super(TAG);
}
public static void startService(final Context context) {
final Intent intent = new Intent(context, RegistrationIntentService.class);
context.startService(intent); //HERE is the line that is causing the crash
}
@Override
public void onHandleIntent(Intent intent) {
InstanceID instanceID = InstanceID.getInstance(this);
try {
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId) , GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
MainSharedPreferences.saveGCMInstanceToken(token, getApplicationContext());
} catch (IOException e) {
e.printStackTrace();
}
}
これがされ
RegistrationIntentService.startService(getApplicationContext());
私MainActivity上のいくつかの情報、それは...
を助けている場合:私のMainActivityクラスから上記のクラスを呼び出しているコードの行public class MainActivity extends SocialActivity implements SeekBar.OnSeekBarChangeListener
public abstract class SocialActivity extends AppCompatActivity implements GraphRequest.GraphJSONObjectCallback
いくつかの古いコミットにジャンプしようとしましたが、同じエラーが発生しました。これは私のAndroid Studioやjavaバージョンに問題があったと私に信じさせてくれました。私は自分のJavaバージョンを更新し、Android Studioを再インストールしましたが、それと同じエラーです。古いバージョンの別のコンピュータでも試しましたが、それと同じエラーです。
GCMからFirebaseに移行して、this guideにしても、同じエラーが再び発生しました。
私は、アプリケーションをクラッシュさせる行をコメントすることができますが、正常に動作しますが、私はもはや通知を受け取りません。
この件に関するお手伝いやアドバイスをいただければ幸いです。
EDIT:ここは同様に私の関連するコンパイル/クラスパスステートメントです... appnameののbuild.gradleで
:アプリのbuild.gradleで
buildscript {
repositories {
jcenter()
}
repositories { mavenCentral() }
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
//...
}
allprojects {
//...
}
android {
//...
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.code.gson:gson:2.5'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:+'
compile "com.google.firebase:firebase-messaging:9.0.0"
//...
}
apply plugin: 'com.google.gms.google-services'
私にとっては役に立ちません –
これは、エラーが発生したときにすでにあったものと一致します。元の投稿を編集して、ライブラリのバージョンを一番下に表示しました。本当にいないようだ「com.android.support:appcompat-v7:23.3.0」と私は「:PLAY-サービス-GCM 8.4.0 com.google.android.gms」を使用していたとき も、このエラーが起こりました意味をなすために... –
は、私はいくつかの他の依存関係がAPPCOMPAT-V7に引っ張っていることを想像:24 :( –