Java 使用Proguard导出APK在实际设备安装中失败
如果我在android studio中导出我的应用程序,同时runProguard=true并将APK安装到真实设备上,我的应用程序会停止并说:不幸的是[yourapp]已经停止 有什么问题吗? 我将proguard-rules.txt文件保留为默认状态:Java 使用Proguard导出APK在实际设备安装中失败,java,android,proguard,Java,Android,Proguard,如果我在android studio中导出我的应用程序,同时runProguard=true并将APK安装到真实设备上,我的应用程序会停止并说:不幸的是[yourapp]已经停止 有什么问题吗? 我将proguard-rules.txt文件保留为默认状态: # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Ap
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Applications/Android Studio.app/sdk/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 *;
#}
没有Proguard,我的应用程序安装和运行都非常完美。你可以做到这一点
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
也许您正在使用库或java反射代码,proguard有时会从您的代码中收缩。。请查看proguard网站,了解android的推荐设置。。使用-KeepClassmembers