简体   繁体   English

Android-twitter4j Proguard错误

[英]Android - twitter4j Proguard error

I was having problems trying to obfuscate my apk - the same problem as reported in this SO question . 我在尝试混淆我的apk时遇到问题-与此问题中报告的问题相同 I applied the accepted answer for that question, and my apk was then built. 我为该问题应用了可接受的答案,然后构建了我的apk。

However, when I run my application, it crashes before the first splash screen is displayed. 但是,当我运行我的应用程序时,它会在显示第一个启动屏幕之前崩溃。

How can I debug this and/or is there anything that might be missing from my proguard-project.txt file??... 我该如何调试和/或在proguard-project.txt文件中可能缺少任何内容?? ...

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

-dontwarn twitter4j.**

NB - I also use the android-support-v4.jar and acra-4.5.0.jar libraries in my app. 注意:我还在我的应用中使用了android-support-v4.jaracra-4.5.0.jar库。

Looks like there were a number of issues. 看起来有很多问题。 Got it sorted in the end. 最终得到了排序。 In case it helps anyone else, here is my full proguard-project.txt file: 万一它对其他人有帮助,这是我完整的proguard-project.txt文件:

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

#
# My classes - start
#

-keep public class com.example.SplashActivity
-keep public class com.example.FragmentActivityWithListener
-keep public class com.example.AbstractHelpActivity
-keep public class com.example.GetContentFromWebTask$CompletedListener

#
# My classes - end
#


#
# Twitter library - start
#

-dontwarn twitter4j.**
-keep class twitter4j.** { *; }

#
# Twitter library - end
#



#
# Google Play Service library - start
#

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

#
# Google Play Service library - end
#



#
# Ads - start
#

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

-keep public class com.google.ads.** {
   public *;
}

#
# Ads - end
#


#
# ACRA - start
#

#ACRA specifics
# Restore some Source file names and restore approximate line numbers in the stack traces,
# otherwise the stack traces are pretty useless
-keepattributes SourceFile,LineNumberTable

# ACRA needs "annotations" so add this...
# Note: This may already be defined in the default "proguard-android-optimize.txt"
# file in the SDK. If it is, then you don't need to duplicate it. See your
# "project.properties" file to get the path to the default "proguard-android-optimize.txt".
-keepattributes *Annotation*

# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
-keep class org.acra.ACRA {
    *;
}

# keep this around for some enums that ACRA needs
-keep class org.acra.ReportingInteractionMode {
    *;
}

-keepnames class org.acra.sender.HttpSender$** {
    *;
}

-keepnames class org.acra.ReportField {
    *;
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter {
    public void addCustomData(java.lang.String,java.lang.String);
    public void putCustomData(java.lang.String,java.lang.String);
    public void removeCustomData(java.lang.String);
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter {
    public void handleSilentException(java.lang.Throwable);
}

#
# ACRA - end
#


#
# Facebook - start
#
-keep class com.facebook.** { *; }
-keepattributes Signature
#
# Facebook - end
#

Add -keep class twitter4j.** { *; } 添加-keep class twitter4j.** { *; } -keep class twitter4j.** { *; } to your proguard-project.txt file. -keep class twitter4j.** { *; }到您的proguard-project.txt文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM