gpt4 book ai didi

Proguard 混淆后 Android 应用程序崩溃

转载 作者:行者123 更新时间:2023-11-30 03:02:53 24 4
gpt4 key购买 nike

我的应用在没有 Proguard 混淆的情况下运行良好。如果我使用 Proguard Obfuscation 导出它然后安装 apk 文件,它会在第一个 Activity 本身上崩溃。我在我的应用程序中使用 AWS android sdk。

我的 Proguard.txt 文件是

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
public static <fields>;
}

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**


#AWS
-keep class org.apache.commons.logging.** { *; }
-keep class com.amazonaws.services.sqs.QueueUrlHandler { *; }
-keep class com.amazonaws.javax.xml.transform.sax.* { public *; }
-keep class com.amazonaws.javax.xml.stream.** { *; }
-keep class com.amazonaws.services.**.model.*Exception* { *; }
-keep class org.codehaus.** { *; }
-keepattributes Signature,*Annotation*
-keep class com.amazonaws.** { *; }

-dontwarn com.amazonaws.**
-dontwarn javax.xml.stream.events.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.apache.commons.logging.impl.**
-dontwarn org.apache.http.conn.scheme.**

-keep class com.fasterxml.jackson.**{*;}
-dontwarn com.fasterxml.jackson.**

我得到的异常是

03-10 11:05:24.552: E/AndroidRuntime(12241): FATAL EXCEPTION: AsyncTask #1
03-10 11:05:24.552: E/AndroidRuntime(12241): Process: com.in.nc.amlooking4.android, PID: 12241
03-10 11:05:24.552: E/AndroidRuntime(12241): java.lang.RuntimeException: An error occured while executing doInBackground()
03-10 11:05:24.552: E/AndroidRuntime(12241): at android.os.AsyncTask$3.done(AsyncTask.java:300)
03-10 11:05:24.552: E/AndroidRuntime(12241): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
03-10 11:05:24.552: E/AndroidRuntime(12241): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
03-10 11:05:24.552: E/AndroidRuntime(12241): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
03-10 11:05:24.552: E/AndroidRuntime(12241): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
03-10 11:05:24.552: E/AndroidRuntime(12241): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
03-10 11:05:24.552: E/AndroidRuntime(12241): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
03-10 11:05:24.552: E/AndroidRuntime(12241): at java.lang.Thread.run(Thread.java:841)
03-10 11:05:24.552: E/AndroidRuntime(12241): Caused by: java.lang.NullPointerException
03-10 11:05:24.552: E/AndroidRuntime(12241): at com.in.nc.amlooking4.android.a.d.<init>(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241): at com.in.nc.amlooking4.android.a.b.b(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241): at com.in.nc.amlooking4.android.a.b.a(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241): at com.in.nc.amlooking4.android.f.a(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241): at com.in.nc.amlooking4.android.f.doInBackground(Unknown Source)
03-10 11:05:24.552: E/AndroidRuntime(12241): at android.os.AsyncTask$2.call(AsyncTask.java:288)
03-10 11:05:24.552: E/AndroidRuntime(12241): at java.util.concurrent.FutureTask.run(FutureTask.java:237)

问题是什么?

最佳答案

正如我在 your forum post 中提到的,请确保您的 AWSCredentials.properties 文件在使用 Proguard 之前位于您的主要 Activity 的包中。

如果这不起作用,请尝试更改为使用Constants 类而不是属性文件。

关于Proguard 混淆后 Android 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22292880/

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