生成登录APK在Android Studio中显示错误

时间:2017-02-12 10:12:19

标签: android android-studio proguard

我已将Android项目从eclipse IDE转换为Android Studio IDE。我在eclipse中使用progurard而没有任何错误,但在将项目转换为android studio后显示错误。当我尝试生成登录apk for build release apk然后显示错误像bellow ..

Error:Execution failed for task ':calApps:transformClassesAndResourcesWithProguardForRelease'.
  

java.io.IOException:请先纠正上述警告。

我的progurard-project.txt就像这样

 .......
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontoptimize
-dontpreverify
-dontwarn android.support.**
-verbose
 ......
-keep public class * extends android.app.Activity

我的build.gradle文件就像这样

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
 // buildToolsVersion '19.1.0'
  useLibrary 'org.apache.http.legacy'
  compileOptions.encoding = 'ISO-8859-1'

 defaultConfig {
    applicationId "com.packagename.apps"
    minSdkVersion 15
    targetSdkVersion 17
    multiDexEnabled true
  }

  buildTypes {
    release {
        minifyEnabled true
       proguardFiles getDefaultProguardFile('proguard-android.txt'),  'proguard-project.txt'


    }
}

dexOptions {
    javaMaxHeapSize "4g"
}

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.0'
compile project(':viewPagerIndicatorLibrary')
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
//compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.android.gms:play-services-maps:9.2.0'
compile 'com.android.support:multidex:1.0.0'

}

请帮助....提前致谢...

2 个答案:

答案 0 :(得分:0)

我发现当SDK,Build Tools和Gradle Plugins的版本不匹配时(在兼容性方面)会发生此错误。

[解决方案是验证我们是否使用它们的最新版本]

gradle插件放在项目的build.gradle(Project:projectName)文件中。

其他版本位于模块的build.gradle(Module:app)文件中。

例如,对于SDK 23,您必须使用Build Tools 23.0.1和gradle plugins 1.3.1版。

我更改了gradle插件版本,然后在更改设置后清理项目以解决我的问题。

答案 1 :(得分:0)

您已在应用中启用了progurd以生成已签名的APK。删除与您在应用程序中使用的库的progurd相关的所有警告,以获取更多详细信息,请参阅this链接