我试图获得我的颤振应用的APK
颤振建立APK
但它返回了这个错误。我不知道这是什么意思。如果你想帮我,我会很高兴的。如果您需要任何额外的细节来解决错误,请在这篇文章中进行注释。
运行分级任务‘组装释放’。R8: com.google.firebase.iid.zzbb类型被引用为来自com.google.firebase.messaging.zzf的接口。
失败:生成失败,出现异常。
问题所在:任务':app:transformClassesAndResourcesWithR8ForRelease'.的执行失败com.android.tools.r8.CompilationFailedException:编译未能完成
的
构建失败在7m32s运行分级任务‘组装释放’.运行分级任务“组装释放”..。完成456.4s (!)!收缩器可能无法优化Java字节码。若要禁用收缩器,请将--no-shrink标志传递给此命令。要了解更多信息,请参见:https://developer.android.com/studio/build/shrink-code Gradle任务assembleRelease退出代码1失败
发布于 2022-01-09 18:09:25
我回答这个问题是因为这是我搜索错误信息时得到的第一个结果之一。
我也犯了同样的错误。R8原来是二进制java文件的“收缩器”,它掩盖了错误背后的问题。在gradle.properties中,我将android.enableR8从true更改为false,然后重建apk。我有一个不同的错误:
...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkReleaseDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class androidx.lifecycle.ViewModelLazy found in modules lifecycle-viewmodel-2.4.0-runtime.jar (androidx.lifecycle:lifecycle-viewmodel:2.4.0) and lifecycle-viewmodel-ktx-2.2.0-runtime.jar (androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0)
Duplicate class androidx.lifecycle.ViewModelProviderKt found in modules lifecycle-viewmodel-2.4.0-runtime.jar (androidx.lifecycle:lifecycle-viewmodel:2.4.0) and lifecycle-viewmodel-ktx-2.2.0-runtime.jar (androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0)
Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
...这个错误是因为我有两个版本的生命周期视图模型运行时: 2.2.0和2.4.0。我搜索了这个项目和插件,发现其中只有一个使用V2.4.0,其余的使用V2.2.0:
def lifecycle_version = "2.4.0"
def arch_version = "2.1.0"
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
// Lifecycles only (without ViewModel or LiveData)
implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"我刚刚将lifecycle_version更改为2.2.0,并且能够在没有错误的情况下构建apk。
别忘了把android.enableR8转回true。
https://stackoverflow.com/questions/61696533
复制相似问题