gpt4 book ai didi

Android Studio 发布签名 apk :app:transformClassesAndResourcesWithProguardForRelease java. io.IOException

转载 作者:行者123 更新时间:2023-12-03 18:08:55 25 4
gpt4 key购买 nike

我刚刚更新到 Android Studio 2.1.1,我正在尝试构建一个发布签名的 apk,但失败并出现以下错误。我该如何解决这个问题?

':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.

这是 build.gradle(模块:app)

完整版: https://gist.github.com/anonymous/65bb2edf94ea58c50de8e0ff107555ce
...
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.company.project"
minSdkVersion 15
targetSdkVersion 23
versionCode 13
versionName "1.5"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
}
}

有关错误消息转储的更多信息
https://gist.github.com/anonymous/9d822c530011b48dab1da60267f9b471

更新:

proguard-rules.pro 的内容
https://gist.github.com/anonymous/9d822c530011b48dab1da60267f9b471

/Users/xxxx/Library/Android/sdk/tools/proguard/proguard-android.txt的内容
https://gist.github.com/anonymous/d5cdfbfd7c1bfe74d594993feb35bd62

/Users/xxxx/Library/Android/sdk/tools/proguard/proguard-project.txt的内容
https://gist.github.com/anonymous/d04cd0299029d4fdd648fb782f2e3021

最佳答案

由于您尚未在 proguard-android.txt 中添加保护规则文件我建议您添加所有必要的规则以从您的项目中发布 apk。

对于 retrofit您需要添加以下规则:

-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions

您还需要添加其他规则,例如,
-keepattributes *Annotation*
-keep class com.google.android.gms.internal.*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgent
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.support.v4.app.DialogFragment

-keep class com.google.android.gms.maps.** { *; }
-keep interface com.google.android.gms.maps.** { *; }

-keepclassmembers class * implements android.os.Parcelable {
static *** CREATOR;
}
# The Maps API uses serialization.
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}

这对于大多数项目都很常见,我已经用于我的项目,请在使用前检查整个规则。

关于Android Studio 发布签名 apk :app:transformClassesAndResourcesWithProguardForRelease java. io.IOException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37457668/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com