- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 Android 中构建一个应用程序,这是 build.gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "myApp"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':geth')
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'org.web3j:core-android:1.1.0'
testCompile 'junit:junit:4.12'
}
当我尝试构建我的应用程序时,我收到以下导致构建失败的警告:
我应该为这些警告添加 -dontwarn 规则吗?是什么原因造成的?
构建失败是因为 67 条警告还是因为最后一条警告:
“有 1 个 Unresolved 对库类成员的引用。 您可能需要更新库版本。”
谢谢。
最佳答案
问题在于 Proguard 的链接问题。ProGuard 优化了字节码,去除了未使用的代码指令,并用短名称混淆了剩余的类、字段和方法。混淆代码使您的 APK 难以进行逆向工程,这在您的应用使用安全敏感功能时尤为重要
有关混淆器的更多信息,请看这里: https://developer.android.com/studio/build/shrink-code.html
build.gradle 中使用的每个库的 proguard 特定规则应放置在“proguard-rules.pro”文件中,如屏幕截图所示。
注意:proguard 文件可以更改。
来到要写的规则。
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keep class com.android.volley.** { *; }
-keep interface com.android.volley.** { *; }
-keep class org.apache.commons.logging.**
-keepattributes *Annotation*
-dontwarn org.apache.**
-keepattributes Annotation,EnclosingMethod,Signature
-keepnames class com.fasterxml.jackson.* { ; }
-dontwarn com.fasterxml.jackson.databind.
-keep class org.codehaus.* { ; }
-keepclassmembers public final enum org.codehaus.jackson.annotate.JsonAutoDetect$Visibility {
public static final org.codehaus.jackson.annotate.JsonAutoDetect$Visibility *; }
-keep public class your.class.* {
public void set_(_);
public ** get*();
}
注意:对于进一步的库 proguard 规则,使用 https://github.com/krschultz/android-proguard-snippets
关于android - 任务 ':app:transformClassesAndResourcesWithProguardForRelease' Android 执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41431523/
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. java.io.I
我正在尝试在控制台中使用 Gradle 构建我的 Android 应用程序。但是收到关于任务':app:transformClassesAndResourcesWithProguardForRelea
在为我的发行版启用缩小功能时,出现以下错误。 Error:Execution failed for task ':app:transformClassesAndResourcesWithProguar
生成签名的 APK: Note: there were 8 unresolved dynamic references to classes or interfaces. Note: there we
我最近将 android studio 更新到 2.3 版,将构建工具更新到 25.0.2、gradle 2.3.0 和 gradle distribution 3.3,现在我在构建项目时得到了这个。
您好,我正在努力为我的项目创建发布版本。我已经通过 SO/Google 帮助在 Progaurd 上尝试了很多东西,但我仍然无法创建发布版本。 有人可以帮我解决这个问题吗?我总是遇到这个问题: Err
我正在尝试导出 apk,我想启用 Proguard,但它抛出了错误。我阅读了很多答案并尝试了但没有奏效。出现以下错误: Warning:Exception while processing task
我正在 Android 中构建一个应用程序,这是 build.gradle 文件: apply plugin: 'com.android.application' android { comp
当我尝试使用发布构建变体构建我的项目时,我收到一个错误: Information:Gradle tasks [:app:assembleRelease] :app:preBuild UP-TO-DAT
当我尝试在 Android Studio 中生成签名时,出现以下错误: Error:Execution failed for task ':app:transformClassesAndResourc
我刚刚将我的项目迁移到 gradle-experimental:0.4.0 以使用 JNI。我已按照说明 here 该项目由一个库和一个应用程序组成。我无法绕过这个错误(尝试了通常的清理和无效缓存/重
我在 React Native 中开发了我的应用程序。我想缩小和缩小我的代码。为了实现这一点,我启用了 proguard 并在 build.gradle 中添加了基于 proguard 的行 这是我的
我正在尝试签署我的应用程序以供发布并且它构建正确,但我想启用 Proguard 我收到以下错误 Error:Execution failed for task ':app:transformClass
每次我在运行我的项目时遇到这个错误。我可以做一个清洁然后再次运行,它可以工作。但这不是最佳解决方案。有什么想法吗? Error:Execution failed for task ':android:
我刚刚更新到 Android Studio 2.1.1,我正在尝试构建一个发布签名的 apk,但失败并出现以下错误。我该如何解决这个问题? ':app:transformClassesAndResou
我是使用混淆器的新手,当我在创建已签名的 api 后构建 api 时,我收到了这些警告和异常。我不知道如何解决它。 这是错误日志: Warning:okio.DeflaterSink: can't f
我正在尝试生成我的 android 应用程序的签名 apk,但任务仍然不成功,给我这个错误: Information:Gradle tasks [:app:assembleRelease] Warni
我已经为我的 Android 应用程序生成了一个 APK(作为尝试),我没有遇到任何问题,APK 已正确生成。 现在,我想在生成 APK 时混淆我的代码,所以我在 build.gradle 文件的 r
当我尝试在 android studio 1.5.1 中生成签名的 Apk 并完成有关此过程的对话框时,我遇到了此消息并中止了构建: Warning:com.squareup.picasso.
我是一名优秀的程序员,十分优秀!