【问题标题】:Android proguard same jar specified twiceAndroid proguard 指定了两次相同的 jar
【发布时间】:2015-03-30 09:55:49
【问题描述】:

我有一个项目,在库文件夹中有两个依赖项目。两者都是我编写的库。 错误:任务 ':app:proguardgmobileRelease' 执行失败。

java.io.IOException: 同一个输入 jar [/Users/Jon/android-app-manager/app/libs/**] 被指定了两次。

主要项目依赖:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:recyclerview-v7:21.0.3'
    compile 'com.android.support:cardview-v7:21.0.3'
    compile 'com.squareup.okhttp:okhttp:2.2.0'
    compile 'com.google.code.gson:gson:2.3'
    compile 'commons-io:commons-io:2.0.1'
    compile 'org.roboguice:roboguice:3.0.1'
    provided 'org.roboguice:roboblender:3.0.1'
    compile 'com.google.code.findbugs:jsr305:1.3.9'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
    compile project(':android-commons')
    compile project(':ormlitewrapper')
    compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar') {
        transitive = true;
    }
}

android-commons 项目依赖:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.squareup.okhttp:okhttp:2.2.0'
    compile 'com.google.code.gson:gson:2.3'
    compile 'commons-io:commons-io:2.0.1'
    compile 'com.google.android.gms:play-services-base:6.5.87'
}

OrmLiteWrapper 项目依赖项:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.j256.ormlite:ormlite-core:4.48'
    compile project(':android-commons')
}

主项目编译2个子项目,ormLiteWrapper也编译android-commons。我无法删除依赖项,也不知道在哪里可以找到循环依赖项的解决方案。它应该在一个地方定义并在另一个地方引用吗? 该问题只会在生成发布 APK 时产生冲突。

【问题讨论】:

    标签: android proguard


    【解决方案1】:

    不要在你的 proguard 文件中使用 -libraryjars-injar-oujar

    【讨论】:

    • 好的,但是我必须使用什么来代替 -libraryjars 或 -injar 或 -oujar 说 proguard 跳过 .jar 文件?
    • 您可以对 jar 文件中的所有类使用 keep 命令。例如使用:'-keep class android.support.v4.** { *; }' 跳过 android-support-v4.jar(查看 jar 中的包结构)
    猜你喜欢
    • 1970-01-01
    • 2012-04-07
    • 1970-01-01
    • 2014-11-24
    • 2019-12-07
    • 1970-01-01
    • 2022-07-05
    • 2011-03-19
    • 1970-01-01
    相关资源
    最近更新 更多