小编Har*_*boj的帖子

使用资源缩减和 Proguard 签署应用程序后应用程序崩溃

这是我在构建签名 APK 时第一次遇到这种类型的异常。我进行了很多搜索,但找不到任何有用的信息来解决这个问题。

任何信息都会对我有很大帮助。因为我已经花了很多时间来解决这个问题。我还想减小 APK 的大小。

我正在创建一个带有以下发布设置和 proguard 的签名 APK

release {
    minifyEnabled true
    shrinkResources true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Run Code Online (Sandbox Code Playgroud)

混淆者:

-dontwarn okhttp3.internal.platform.*
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
-dontwarn javax.annotation.**
-dontwarn kotlin.Unit
-dontwarn retrofit2.-KotlinExtensions
Run Code Online (Sandbox Code Playgroud)

构建签名的 APK 后,我尝试对其进行测试,发现 google 和 facebook 登录无法正常工作(我没有使用任何其他方式登录),并且当我打开请求 API 端点的隐私政策或条款活动时,应用程序崩溃改造 2.

implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
Run Code Online (Sandbox Code Playgroud)

下面是崩溃的 logcat。

2018-12-31 15:24:42.054 15126-15126/com.sathi E/UncaughtException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.sathi.c.a.i$a.a()' on a null object reference
        at com.sathi.activities.PrivacyPolicyActivity$1.a(Unknown Source)
        at com.sathi.c.d$3.a(Unknown Source)
        at d.h$a$1$1.run(Unknown Source)
        at …
Run Code Online (Sandbox Code Playgroud)

android proguard apk android-studio android-proguard

4
推荐指数
1
解决办法
1885
查看次数