Error using Push Notification ,java.lang.IncompatibleClassChangeError: android.support.v4.content.ContextCompat Error
Error using Push Notification ,java.lang.IncompatibleClassChangeError: android.support.v4.content.ContextCompat Error
我的app.gradle
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.mss.plix"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
//====================Add below two line=============
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext {
permissionsDispatcherVersion = '2.1.2'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.jakewharton:butterknife:7.0.1'
testCompile 'junit:junit:4.12'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.isseiaoki:simplecropview:1.1.4'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
compile 'com.github.aakira:expandable-layout:1.4.1@aar'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
apt "com.github.hotchemi:permissionsdispatcher-processor:2.1.3"
compile project(':library')
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support:support-v4:24.2.1'
}
repositories {
jcenter()
}
我的项目Gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-rc2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
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
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
尝试获取令牌时我的日志输出
E/UncaughtException: java.lang.IncompatibleClassChangeError: android.support.v4.content.ContextCompat
at com.google.android.gms.iid.zzd.zzeC(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.mss.plix.Notifications.GCMRegistrationIntentService.registerGCM(GCMRegistrationIntentService.java:43)
at com.mss.plix.Notifications.GCMRegistrationIntentService.onHandleIntent(GCMRegistrationIntentService.java:30)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)
我正在我的应用程序中实现推送通知,但是当我调用 GcmIntentService
时,我收到了我已经在我的日志输出中发布的错误。我也尝试使用 FCM 但遇到了同样的问题。如果有人实现了这个,那么请帮忙。提前致谢。
**> 得到我问题的答案错误是因为使用播放服务
9.0.0
But when we update the play service to 9.4.0 and same as firebase
dependency .and the main issue in my gradle is apply plugin:
'com.google.gms.google-services' will not come at the top of gradle it
will come at the bottom after dependency .And i dont know why this
works fine and my token and context compact issue also got resolved.**
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.mss.plix"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
//====================Add below two line=============
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext {
permissionsDispatcherVersion = '2.1.2'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.jakewharton:butterknife:7.0.1'
testCompile 'junit:junit:4.12'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.isseiaoki:simplecropview:1.1.4'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
compile 'com.github.aakira:expandable-layout:1.4.1@aar'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
apt "com.github.hotchemi:permissionsdispatcher-processor:2.1.3"
compile project(':library')
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support:support-v4:24.2.1'
}
apply plugin: 'com.google.gms.google-services'
repositories {
jcenter()
}
应该是这样的。 :)
我的app.gradle
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.mss.plix"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
//====================Add below two line=============
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext {
permissionsDispatcherVersion = '2.1.2'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.jakewharton:butterknife:7.0.1'
testCompile 'junit:junit:4.12'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.isseiaoki:simplecropview:1.1.4'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
compile 'com.github.aakira:expandable-layout:1.4.1@aar'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
apt "com.github.hotchemi:permissionsdispatcher-processor:2.1.3"
compile project(':library')
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support:support-v4:24.2.1'
}
repositories {
jcenter()
}
我的项目Gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-rc2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
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
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
尝试获取令牌时我的日志输出
E/UncaughtException: java.lang.IncompatibleClassChangeError: android.support.v4.content.ContextCompat
at com.google.android.gms.iid.zzd.zzeC(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.mss.plix.Notifications.GCMRegistrationIntentService.registerGCM(GCMRegistrationIntentService.java:43)
at com.mss.plix.Notifications.GCMRegistrationIntentService.onHandleIntent(GCMRegistrationIntentService.java:30)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)
我正在我的应用程序中实现推送通知,但是当我调用 GcmIntentService
时,我收到了我已经在我的日志输出中发布的错误。我也尝试使用 FCM 但遇到了同样的问题。如果有人实现了这个,那么请帮忙。提前致谢。
**> 得到我问题的答案错误是因为使用播放服务
9.0.0
But when we update the play service to 9.4.0 and same as firebase dependency .and the main issue in my gradle is apply plugin: 'com.google.gms.google-services' will not come at the top of gradle it will come at the bottom after dependency .And i dont know why this works fine and my token and context compact issue also got resolved.**
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.mss.plix"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
//====================Add below two line=============
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext {
permissionsDispatcherVersion = '2.1.2'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.jakewharton:butterknife:7.0.1'
testCompile 'junit:junit:4.12'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.isseiaoki:simplecropview:1.1.4'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
compile 'com.github.aakira:expandable-layout:1.4.1@aar'
compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
apt "com.github.hotchemi:permissionsdispatcher-processor:2.1.3"
compile project(':library')
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support:support-v4:24.2.1'
}
apply plugin: 'com.google.gms.google-services'
repositories {
jcenter()
}
应该是这样的。 :)