【发布时间】:2015-10-07 23:31:59
【问题描述】:
Android Studio 1.3.1
我有以下文件:
%appname%\app\build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.example.app"
minSdkVersion 9
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:21.1.2'
compile 'com.github.PhilJay:MPAndroidChart:v2.0.8'
}
%appname%\app\proguard-project.txt
-dontwarn com.google.android.gms.
-keep class com.google.android.gms.** { *; }
-dontwarn android.support.v7.
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
-dontwarn com.github.PhilJay.
-keep class com.github.PhilJay.** { *; }
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
(我在这里尝试了很多东西。仍在学习确保一切都是 100% 正确)
当我尝试生成签名的 APK 时出现错误:
错误:任务 ':app:packageRelease' 执行失败。无法 计算哈希 W:\android-studio-projects\%appname%\app\build\intermediates\classes-proguard\release\classes.jar
在此之前我收到这两个警告:
警告:com.google.android.gms.internal.zzhu:找不到引用 类 android.security.NetworkSecurityPolicy 警告:有 3 个 对类或接口的未解析引用。 您可能需要添加缺少的库 jar 或更新它们的版本。 如果您的代码在没有缺少类的情况下工作正常,则可以抑制 带有“-dontwarn”选项的警告。 (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) 处理任务时出现异常
现在如果我改成
minifyEnabled true
它有效,但是...我更喜欢使用 minify。我不确定警告是否是原因?毕竟,它声明可以抑制警告,所以这些警告不一定是错误的原因?
【问题讨论】:
-
我现在添加了更多信息。我希望我不会被否决,因为我相信我已经尝试了所有可以在网上找到的东西,包括 SO
-
我对 Android Studio 1.4 有同样的问题
标签: android-studio android-proguard