代码之家  ›  专栏  ›  技术社区  ›  Ferran Maylinch

获取重复条目:Android Studio 3.0的META-INF/LICENSE

  •  2
  • Ferran Maylinch  · 技术社区  · 7 年前

    当尝试运行我的Android应用程序时(在我将Android Studio更新到3.0并根据需要更新一些LIB之后),我得到:

    Error:Execution failed for task ':MyApp:transformClassesWithStackFramesFixerForDebug'.
    > com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.builder.utils.FileCache$FileCreatorException: java.util.zip.ZipException: duplicate entry: META-INF/LICENSE
    

    META-INF/LICENSE 一段时间前使用来自的解决方案成功归档 here 但是自从我升级到Android Studio 3.0后,我就遇到了这个错误,我不知道如何修复它。

    您知道如何排除该文件或消除此错误吗?

    buildscript {
        repositories {
            jcenter()
            maven { url 'https://maven.fabric.io/public' }
        }
        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }
    
    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    
    repositories {
        mavenLocal()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    
    allprojects {
        repositories {
            google()
        }
    }
    
    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.2"
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    
        dexOptions {
            javaMaxHeapSize "2g"
        }
    
        defaultConfig {
            versionCode 15040300
            versionName "4.3.0"
            minSdkVersion 15
            targetSdkVersion 26
            multiDexEnabled true
        }
    
        // http://stackoverflow.com/a/21000452/1121497
        packagingOptions {
            pickFirst 'META-INF/*'
        }
    
        final Properties signingProps = new Properties()
        final File signingFile = file("signing.properties")
        if (!signingFile.exists()) {
            throw new RuntimeException("You need your signing properties in a git-ignored file: " + signingFile.getAbsolutePath())
        }
        signingProps.load(new FileInputStream(file(signingFile)))
    
        signingConfigs {
            release {
                storeFile file(signingProps['storeFile'])
                storePassword signingProps['storePassword']
                keyAlias signingProps['keyAlias']
                keyPassword signingProps['keyPassword']
            }
        }
        buildTypes {
            release {
                signingConfig signingConfigs.release
            }
        }
    }
    
    dependencies {
    
        compile 'com.android.support:appcompat-v7:26.1.0'
        compile 'com.android.support:mediarouter-v7:26.1.0'
        compile 'com.android.support:recyclerview-v7:26.1.0'
        compile 'com.android.support:design:26.1.0'
    
        compile 'com.android.support:multidex:1.0.2'
    
        compile 'com.google.android.gms:play-services-maps:11.4.2'
        compile 'com.google.android.gms:play-services-analytics:11.4.2'
        compile 'com.google.android.gms:play-services-gcm:11.4.2'
        compile 'com.google.firebase:firebase-appindexing:11.4.2'
        compile 'com.google.firebase:firebase-core:11.4.2'
    
        compile 'commons-codec:commons-codec:1.9'
        compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
        compile 'com.github.chrisbanes.photoview:library:1.2.2'
        compile 'de.greenrobot:eventbus:2.4.0'
        compile 'info.hoang8f:android-segmented:1.0.5'
        compile 'com.facebook.android:facebook-android-sdk:4.27.0'
        compile 'com.facebook.android:notifications:1.0.2'
        compile 'io.card:android-sdk:5.4.2'
        compile 'me.dm7.barcodescanner:zxing:1.9'
        compile 'com.google.android.exoplayer:exoplayer:r2.2.0'
        compile 'com.squareup.retrofit:retrofit:1.9.0'
        compile 'com.squareup.okhttp:okhttp:2.2.0'
        compile 'io.reactivex:rxandroid:1.1.0'
        compile 'io.reactivex:rxjava:1.1.0'
    
        compile fileTree(dir: '../libs', include: '*.jar')
    
        compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
            transitive = true;
        }
    }
    
    apply plugin: 'com.google.gms.google-services'
    
    2 回复  |  直到 7 年前
        1
  •  2
  •   Ferran Maylinch    7 年前

    虽然我不知道到底发生了什么,但下面是我为解决问题所做的。

    LICENSE , LICENSE_1 LICENSE_2 . 出于某种原因,他们似乎被误认为是同一个文件。

    我刚刚删除了所有 LICENSE_* 文件,仅保留 许可证 ,问题就解决了。

    注意:jar位于使用加载的文件中 compile fileTree(dir: '../libs', include: '*.jar')

    另请参见 here 关于排除文件。

        2
  •  -1
  •   Liem Vo    7 年前

    尝试使用

    packagingOptions {
            pickFirst "anyFileWillDo"
            exclude "/META-INF/**"
     }