获取重复条目:META-INF/LICENSE with Android Studio 3.0
Getting duplicate entry: META-INF/LICENSE with Android Studio 3.0
尝试 运行 我的 Android 应用程序时(在我将 Android Studio 更新到 3.0 并根据需要更新了一些库之后),我得到:
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
文件,但是自从我更新到 Android Studio 3.0 后,我收到了那个错误,我不知道怎么办修复它。
您知道我如何排除该文件或消除此错误吗?
我的gradle文件如下:
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
}
//
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'
试试
packagingOptions {
pickFirst "anyFileWillDo"
exclude "/META-INF/**"
}
虽然我不知道到底发生了什么,但这是我解决问题的方法。
在我的 jar 文件中,有一个包含多个名为 LICENSE
、LICENSE_1
和 LICENSE_2
的许可证文件。出于某种原因,它们似乎被误认为是同一个文件。
我刚刚删除了所有 LICENSE_*
个文件,只留下 LICENSE
,问题就消失了。
注意:jar 在使用 compile fileTree(dir: '../libs', include: '*.jar')
加载的文件中
另请参阅 关于排除文件。
尝试 运行 我的 Android 应用程序时(在我将 Android Studio 更新到 3.0 并根据需要更新了一些库之后),我得到:
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
文件,但是自从我更新到 Android Studio 3.0 后,我收到了那个错误,我不知道怎么办修复它。
您知道我如何排除该文件或消除此错误吗?
我的gradle文件如下:
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
}
//
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'
试试
packagingOptions {
pickFirst "anyFileWillDo"
exclude "/META-INF/**"
}
虽然我不知道到底发生了什么,但这是我解决问题的方法。
在我的 jar 文件中,有一个包含多个名为 LICENSE
、LICENSE_1
和 LICENSE_2
的许可证文件。出于某种原因,它们似乎被误认为是同一个文件。
我刚刚删除了所有 LICENSE_*
个文件,只留下 LICENSE
,问题就消失了。
注意:jar 在使用 compile fileTree(dir: '../libs', include: '*.jar')
另请参阅