1

我正在尝试生成已签名的apk版本。但跟上消息框下面的警告失败:无法在android studio中生成已签名的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:[email protected]') { 
     transitive = true; 
    } 
} 
+0

尝试清理所有项目! –

+0

@NiravRanpara也尝试过...但仍然得到相同的警告消息。 – Ruchir

+0

请参阅此[链接](http://stackoverflow.com/a/33953133/2078074)。希望它可以帮助你。 – Lawrance

回答

0

这个错误发生在当版本的SDK,构建工具和Gradle插件不匹配(就兼容性而言)。解决方案是验证您是否正在使用它们的最新版本。 gradle插件放置在项目的build.gradle文件中。其他版本位于模块的build.gradle文件中。对于示例,对于SDK 23,您必须使用构建工具23.0.1和gradle 插件1.3.1版。

更改设置后清理项目。 refer this question

相关问题