-1

如果我将 minSdkVersion 保留为 15,则在更新我的应用程序 bat 时遇到问题,我无法生成签名的 apk,因为我收到此错误:

错误:任务“:transformClassesWithJarMergingForRelease”执行失败。com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android/support/v4/database/DatabaseUtilsCompat.class

minSdkVersion设置为25时,没有问题。

这是我的build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:multidex:1.0.0'
}

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.1'
    buildToolsVersion '25.0.1'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 23
        multiDexEnabled true
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.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')
    }
}

谢谢你们!

4

2 回答 2

0

试试这个作为你的dependencies条目:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile ('com.android.support:multidex:1.0.1'){
        exclude module: 'support-v4'
    }
    compile 'com.android.support:support-v4:25.0.1'
    compile('com.android.support:appcompat-v7:25.0.1') {
        exclude module: 'support-v4'
    }
}
于 2017-07-13T16:36:56.020 回答
0

我找到了解决方案。在 libs 文件夹中,我找到了一个创建副本的库。该库是“android-support-v4.jar”

于 2017-07-14T09:10:32.387 回答