Java com.google.android.gms.common.internal.safe parcel.safe 找不到parcelable
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41408514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
com.google.android.gms.common.internal.safe parcel.safe parcelable not found
提问by Panache
I am trying to add notification services to my app using FCM and tutorial given on https://www.simplifiedcoding.net/firebase-cloud-messaging-android/Everything has done and working like getting token etc. but now after creating messaging handler, I started getting error:
我正在尝试使用 FCM 和https://www.simplifiedcoding.net/firebase-cloud-messaging-android/ 上给出的教程将通知服务添加到我的应用 程序中,我开始收到错误:
Error:(22, 26) error: cannot access AbstractSafeParcelable
class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found
and build is failed. Pls guide. code for gradle is:
并且构建失败。请指导。gradle 的代码是:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven {
url "https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/"
}
}
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "jss.smartapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
}
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'
})
testCompile 'junit:junit:4.12'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
//Apache IO
compile files('libs/commons-io-2.5.jar')
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
//Crashlytics
compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
transitive = true;
}
//Dropbox
compile 'com.dropbox.core:dropbox-core-sdk:2.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.4.0'
//FTP
compile files('libs/ftp4j-1.7.2.jar')
//Http
compile 'com.squareup.okhttp3:okhttp:3.4.2'
//Instamojo
compile 'com.instamojo:android-sdk:+'
//Material Design Didalogs
compile 'com.afollestad.material-dialogs:commons:0.9.1.0'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
//GSON
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
//multidex dependency
compile 'com.android.support:multidex:1.0.1'
//box dependencies
compile 'com.box:box-java-sdk:2.1.1'
compile 'com.box:box-android-sdk:3.0.2'
//google drive dependency
compile 'com.google.android.gms:play-services-drive:10.0.1'
//one drive dependency
compile('com.onedrive.sdk:onedrive-sdk-android:1.2+') {
transitive = false
}
compile('com.microsoft.services.msa:msa-auth:0.8.+')
compile('com.microsoft.aad:adal:1.1.+')
//justify test
compile 'com.github.bluejamesbond:textjustify-android:2.1.6'
//image downnloader
/*compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'*/
//Glide Image downloading
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.google.firebase:firebase-messaging:9.2.1'
}
apply plugin: 'com.google.gms.google-services'
回答by GuillaumeAgis
In your Gradle file all the versions of google-play-service and firebase should use the same version.
在您的 Gradle 文件中,所有版本的 google-play-service 和 firebase 都应该使用相同的版本。
As you are using :
当您使用时:
compile 'com.google.android.gms:play-services-drive:10.0.1'
You should use :
你应该使用:
compile 'com.google.firebase:firebase-messaging:10.0.1'
// and not 9.2.1
compile 'com.google.firebase:firebase-messaging:10.0.1'
// 而不是 9.2.1
回答by David A
It's an Android Studio bug, it is NOT offering to automatically upgrade firebase libs like it does for play-services* libs.
这是一个 Android Studio 错误,它不提供像 play-services* 库那样自动升级 firebase 库。
autoupdate
自动更新
compile 'com.google.android.gms:play-services-drive:10.0.1'
no autoupdate (need to manually up the version to same as play-services*)
没有自动更新(需要手动将版本升级到与 play-services* 相同的版本)
compile 'com.google.firebase:firebase-messaging:10.0.1'
回答by Alfred Ayi-bonte
Make sure your google service version matches your firebase version. currently compile 'com.google.android.gms:play-services-drive:10.0.1' does not match compile 'com.google.firebase:firebase-messaging:9.2.1' What you have to do is to change 'com.google.firebase:firebase-messaging:9.2.1' to 'com.google.firebase:firebase-messaging:10.0.1' so that the versions matches.
确保您的 google 服务版本与您的 firebase 版本匹配。当前编译 'com.google.android.gms:play-services-drive:10.0.1' 与编译 'com.google.firebase:firebase-messaging:9.2.1' 不匹配,您需要做的是更改 'com .google.firebase:firebase-messaging:9.2.1' 到 'com.google.firebase:firebase-messaging:10.0.1' 以便版本匹配。
回答by Qohat Pretel Polo
You must have all the google play service line in the same version:
您必须在同一版本中拥有所有 google play 服务线:
compile 'com.google.android.gms:play-services:11.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
回答by garry
Use something like this:
使用这样的东西:
dependencies {
compile 'com.google.android.gms:play-services:11.0.1'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
}
apply plugin: 'com.google.gms.google-services'
Make sure apply plugin comes below dependencies.
确保应用插件低于依赖项。
回答by Tina
What finally saved me:
最终救了我的是什么:
In android studio, switch to Project view instead of Android view. Delete .gradle folderm and also the gradle.properties file. Clean the project. Sync gradle again.
在 android studio 中,切换到项目视图而不是 Android 视图。删除 .gradle folderm 和 gradle.properties 文件。清理项目。再次同步gradle。
I have no clue why this worked. Deleting only the .gradle folder didn't do the job and the newly made gradle.properties is exactly the same as the old one! But my issue is fixed.
我不知道为什么这有效。只删除 .gradle 文件夹并没有完成这项工作,新制作的 gradle.properties 与旧的完全一样!但我的问题是固定的。