Android 生成已签名的apk时生成失败
如果我为调试版本启用r8/proguard,则我的应用程序构建不会出现任何错误。但是如果我试图生成一个签名的apk,那么构建就会失败,尽管我已经从okhttp和改型的github repo中为proguard/r8添加了规则 当我使用--info运行它时,Gradle错误日志 我的proguard-rules.pro文件:Android 生成已签名的apk时生成失败,android,android-studio,gradle,Android,Android Studio,Gradle,如果我为调试版本启用r8/proguard,则我的应用程序构建不会出现任何错误。但是如果我试图生成一个签名的apk,那么构建就会失败,尽管我已经从okhttp和改型的github repo中为proguard/r8添加了规则 当我使用--info运行它时,Gradle错误日志 我的proguard-rules.pro文件: -dontobfuscate -keep public class bd.edu.daffodilvarsity.classmanager.common.models.* {
-dontobfuscate
-keep public class bd.edu.daffodilvarsity.classmanager.common.models.* { *; }
# Rules for OkHttp library
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*
# OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn org.conscrypt.**
-dontwarn okhttp3.internal.platform.**
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod
# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}
# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**
# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit
# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
gradle-wrapper.properties
#Mon Jan 25 03:03:02 BDT 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
这是R8中的一个错误-与此密切相关。它应该在R8编译器的版本2.2.53中修复。该修复程序正在studio中运行,应不晚于studio 4.2 RC1。可以通过将以下内容添加到顶级build.gradle文件来使用版本2.2.53:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.21'
repositories {
google()
jcenter()
maven {
url "http://storage.googleapis.com/r8-releases/raw/master"
}
}
dependencies {
classpath 'com.android.tools:r8:2.1.75'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://www.jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
repositories {
maven {
url 'https://storage.googleapis.com/r8-releases/raw'
}
}
dependencies {
classpath 'com.android.tools:r8:2.2.53' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:X.Y.Z' // Your current AGP version.
}
}
这是R8中的一个错误-与此密切相关。它应该在R8编译器的版本2.2.53中修复。该修复程序正在studio中运行,应不晚于studio 4.2 RC1。可以通过将以下内容添加到顶级build.gradle文件来使用版本2.2.53:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.21'
repositories {
google()
jcenter()
maven {
url "http://storage.googleapis.com/r8-releases/raw/master"
}
}
dependencies {
classpath 'com.android.tools:r8:2.1.75'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://www.jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
repositories {
maven {
url 'https://storage.googleapis.com/r8-releases/raw'
}
}
dependencies {
classpath 'com.android.tools:r8:2.2.53' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:X.Y.Z' // Your current AGP version.
}
}
这看起来像是R8编译器的问题,可能与相同,因此请继续关注。您可以尝试切换到R8版本2.1.86或2.2.51(您已经有了版本2.1.75的特定参考,但AGP4.1.2实际上与2.1.86捆绑在一起)。否则,如果您可以共享一个,这将有助于查找问题。你可以私下和我分享sgjesse@google.com及mkroghj@google.com.I尝试降级AGP并在不同的R8版本之间切换,但没有解决我的问题。正如您所提到的,我已经创建了编译器转储。如果你看一看,那就太慷慨了。我已经在谷歌硬盘上分享了这两封邮件。谢谢你的帮助。我们(R8团队)可以重现这个问题,当我们有更多信息时会回来。请关注更新。这看起来像是R8编译器的问题,可能与相同,因此请继续关注。您可以尝试切换到R8版本2.1.86或2.2.51(您已经有了版本2.1.75的特定参考,但AGP4.1.2实际上与2.1.86捆绑在一起)。否则,如果您可以共享一个,这将有助于查找问题。你可以私下和我分享sgjesse@google.com及mkroghj@google.com.I尝试降级AGP并在不同的R8版本之间切换,但没有解决我的问题。正如您所提到的,我已经创建了编译器转储。如果你看一看,那就太慷慨了。我已经在谷歌硬盘上分享了这两封邮件。谢谢你的帮助。我们(R8团队)可以重现这个问题,当我们有更多信息时会回来。请关注更新。