我正在尝试生成已签名的apk用于发布。但它仍然在消息框中跟随警告失败:
Error:Execution failed for task ':msapp_V_520:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.
我尝试通过在proguard-rules.pro文件中添加 -dontwarn 和 -dontnote 来解决此问题。很少有警告消失但仍然出现错误。我不知道我要做什么来解决这些警告并生成apk。这就是我在消息框中收到的内容:
Note: there were 6 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 4 classes trying to access generic signatures using reflection.
You should consider keeping the signature attributes
(using '-keepattributes Signature').
(http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 80 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using '-keep').
(http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 17 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 1 class casts of dynamically created class instances.
You might consider explicitly keeping the mentioned classes and/or
their implementations (using '-keep').
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclasscast)
Note: there were 4 accesses to class members by means of introspection.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
Warning:there were 4 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
:msapp_V_520:transformClassesAndResourcesWithProguardForRelease FAILED
Error:Execution failed for task ':msapp_V_520:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.
proguard-rules.pro文件
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\user\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# 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 com.nostra13.example.universalimageloader.**
-dontnote com.nostra13.example.universalimageloader.**
-dontwarn com.facbook.**
-dontnote com.facbook.**
-dontwarn com.ikimuhendis.ldrawer.**
-dontnote com.ikimuhendis.ldrawer.**
-dontwarn com.loadindicators.adrianlesniak.library.**
-dontnote com.loadindicators.adrianlesniak.library.**
-dontwarn com.handmark.pulltorefresh.library.**
-dontnote com.handmark.pulltorefresh.library.**
-dontwarn com.pullToRefresh.**
build.gradle文件
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
config {
storeFile file('keystorePath')
storePassword 'xyz...'
keyAlias 'xyz...'
keyPassword 'somePwd'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example..."
minSdkVersion 14
targetSdkVersion 20
useLibrary 'org.apache.http.legacy'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
signingConfig signingConfigs.config
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
signingConfig signingConfigs.config
}
}
dexOptions {
incremental true
}
productFlavors {
}
}
dependencies {
compile project(':comnostra13exampleuniversalimageloaderHomeActivity')
compile project(':nineoldandroid')
compile project(':libraryActionbar')
compile project(':pullToRefresh')
compile project(':facebook')
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:23.3.0'
compile files('libs/AF-Android-SDK-v2.3.1.19.jar')
compile files('libs/classes.jar')
compile files('libs/CleverTapAndroidSDK-v1-20150903.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile project(':LoadIndicatorLibrary')
compile 'com.nispok:snackbar:2.11.+'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
}
答案 0 :(得分:0)
当SDK,Build Tools和Gradle Plugins的版本不匹配时(在兼容性方面),会发生此错误。解决方案是验证您是否使用它们的最新版本。 gradle插件放在项目的build.gradle文件中。其他版本位于模块的build.gradle文件中。对于示例,对于 SDK 23 ,您必须使用构建工具23.0.1 并使用gradle 插件版本1.3.1。强>
更改设置后清洁项目。 refer this question