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

相關問題