克隆项目https://github.com/googlesamples/google-services/tree/master/android/gcm,一切正常。
当我尝试添加模块" App Engine后端与Google云消息传递"使用向导我收到以下错误:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.transform.api.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
现在我尝试在build.gradle defaultConfig
中添加它multiDexEnabled true
并清理项目并重新编译。但我总是得到同样的错误。最后我尝试从项目中删除表单(想要恢复正常运行),但是我收到以下错误:
Installing gcm.play.android.samples.com.gcmquickstart
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/gcm.play.android.samples.com.gcmquickstart"
pkg: /data/local/tmp/gcm.play.android.samples.com.gcmquickstart
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION perm=com.example.gcm.permission.C2D_MESSAGE pkg=it.elipse.tnttrackingapp]
DEVICE SHELL COMMAND: pm uninstall gcm.play.android.samples.com.gcmquickstart
DELETE_FAILED_INTERNAL_ERROR
有人可以帮助我吗?你采取了相同的步骤,你发现自己在我的情况下?提前谢谢
答案 0 :(得分:0)
<强>解决强>
大家好我自己找到了答案。我希望它可以帮助有同样问题的人。 当Android Studio生成后端模块时,在build.gradle(模块:app)的依赖关系结束处添加此行
compile project(path: ':backend', configuration: 'android-endpoints')
你有这样的事情:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:palette-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile project(path: ':backend', configuration: 'android-endpoints')
}
解决方法是将自动生成的行移到dependecies声明的顶部,如下所示:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(path: ':backend', configuration: 'android-endpoints')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:palette-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
}
<强>更新强>
如果你不解决,请尝试:
Build->Make Project
Build->Make Module 'app'
Build->Clean Project
Build->Rebuild Project