Android Gradle ProguardRelease失败

时间:2014-09-05 05:36:41

标签: android gradle

在我的项目中,我有许多依赖项目可用。每个项目都有support-v4-19.1.0.jar文件。

当我尝试使用gradle构建应用程序时,ProguardRelease任务失败并出现以下错误。

* What went wrong:

任务执行失败':CurrenexMobile:proguardRelease'。

  

java.io.IOException:不能写[build \ in   termediates \ classes-proguard \ release \ classes.jar](不能读取[build \ intermediates \ explosion-aar \ libs \ support-v4-19.1.0.jar(;;;;;;; META-INF) /MANIFEST.MF)](重复压缩   ry [android / support / v4 / c / a.class == support-v4-19.1.0.jar:android / support / v4 / os /   ParcelableCompat.class]))

有人可以提出一些想法来解决这个问题吗?

编辑:

的build.gradle

apply plugin: 'android-library'

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        resources.srcDirs = ['src']
        java.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
     debug.setRoot('build-types/debug')
     release.setRoot('build-types/release')
}
}

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile(group: 'android', name: 'Lib1', version: '3.7.5', ext: 'aar')
compile(group: 'android', name: 'Lib2', version: '2.0.2', ext: 'aar')
compile(group: 'android', name: 'Lib3', version: '1.2.7', ext: 'aar')
compile(group: 'android', name: 'Lib4', version: '2.2.1', ext: 'aar')
compile 'de.greenrobot:eventbus:2.2.+'
}

Proguard文件

-keep class android.support.v4.** { *; }


# MonkeyTalk Time
-dontwarn com.gorillalogic.**
-keep class com.gorillalogic.** { *; }
-keep interface com.gorillalogic.** { *; }
-keep enum com.gorillalogic.** { *; }

# To skip renaming file and method names
-keepattributes SourceFile,LineNumberTable

# EventBus
-keepclassmembers class ** {
 public void onEvent(**);
}

#Skip Logger
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** e(...);
}

2 个答案:

答案 0 :(得分:0)

  

Lib1,libb2 ..所有项目都有支持-v4-19.1.0.jar

那是你的问题。修复这些库以依赖support-v4工件(compile 'com.android.support:support-v4:19.1.0'),而不是将JAR复制到那些项目的libs/目录中。

答案 1 :(得分:-1)

清理并构建您的项目。它对我有用。