java - Proguard 在尝试使用相机发送图片时导致应用程序崩溃

标签 java android proguard apk gae-eclipse-plugin

我的应用程序已经过测试并且工作正常。但是当我尝试测试发布的 apk 时,它崩溃了。我包括了我的 proguard 文件和测试发布 apk 时得到的错误日志。基本上,当我通过 Intent 拍照然后尝试通过互联网将图片发送给收件人后,它就会崩溃。同样,我的应用程序运行良好:直到 proguard 加入其中。

注意:

发送图像的代码是 RunnableThread 启动如 new Thread(runnable).start() ;非常基本的东西。同样,代码在 proguard 之外工作。

我的project.properties文件使用默认的 android 文件和我的。

Android 混淆器:

# 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.**

项目proguard:

# My addition

-keepclassmembers class com.mycompany.mygame.** {
    public static <fields>;
}

# -keep public class com.mycompany.mygame.** { *; }
-dontwarn com.mycompany.mygame.**

# -keep public class android.support.** { *; }
-dontwarn android.support.**

# -keep public class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**

# -keep public class com.google.common.** { *; }
-dontwarn com.google.common.**

# -keep public class org.apache.commons.** { *; }
-dontwarn org.apache.commons.**

# -keep public class org.apache.http.impl.** { *; }
-dontwarn org.apache.http.impl.**

# -keep public class android.net.http.AndroidHttpClient { *; }
-dontwarn android.net.http.AndroidHttpClient

错误日志:

05-03 17:40:45.704: E/CameraApp(5068): [SoundController.java:468:onDestroy()] onDestroy-end, sound_pool release 2/2
05-03 17:40:52.829: E/AndroidRuntime(5327): FATAL EXCEPTION: Thread-514
05-03 17:40:52.829: E/AndroidRuntime(5327): xb: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'xc'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html.)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at xc.a(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at xe.run(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at java.security.AccessController.doPrivileged(AccessController.java:45)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at xc.a(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at xc.a(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at xc.b(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at afj.<init>(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at afr.<init>(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at gu.a(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at ha.a(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at ha.run(Unknown Source)
05-03 17:40:52.829: E/AndroidRuntime(5327):     at java.lang.Thread.run(Thread.java:856)
05-03 17:40:52.829: E/AndroidRuntime(5327): Caused by: java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'xc'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html.
05-03 17:40:52.829: E/AndroidRuntime(5327):     ... 12 more
05-03 17:41:13.829: E/Trace(5606): error opening trace file: No such file or directory (2)

最佳答案

明显的标志是这一行:

05-03 17:40:52.829: E/AndroidRuntime(5327): Caused by: java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'xc'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html.

看起来一些 Apache 日志记录的类已被 Proguard 重命名,并且从 Proguard 配置文件中您可以看到

# -keep public class org.apache.commons.** { *; }

标记为注释(带有“#”前缀),因此我会删除上面一行中的“#”,从而告诉 Proguard 不要重命名包 org.apache.commons 中的类,然后重试。

关于java - Proguard 在尝试使用相机发送图片时导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16369536/

相关文章:

java - 带有 appcompat 库 v7 的 ActionBar(java.lang.IllegalStateException : You need to use a Theme. AppCompat 主题)

android - Proguard 和 Preference 数据存储

android - 生成签名 APK 时改造 2.3.0 错误

Java weblogic 错误,由 : java. lang.IllegalArgumentException 引起

android - 弹出验证 native 密码android

java - Weblogic 10.3.6 上的 Weld

android - 如何在 Android 中按文件名或日期按升序或降序对文件或文件夹进行排序?

android - Sqlite 数据库未插入在 Proguard 构建中使用脚本

java - 类的某些对象可以具有特定的行为,而其他对象则没有

java - 从 JTextfield 获取输入