我克隆了一个github仓库,因为我想研究代码,但是当我试图在Android Studio中构建它时,我遇到了一些麻烦。添加google maven存储库(根据Android Studio的提示)并更新Gradle插件版本和Grade版本(分别更新为3.5.2和5.4.1)后,构建失败,原因是以下错误:
原因:重复录入:META-INF/MANIFEST.MF
更具体地说
原因:java.util.zip.ZipException:重复条目:META-INF/MANIFEST.MF
以下是我的项目级build.gradle文件:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
字符串
以下是我的模块build.gradle文件(在尝试任何操作之前):
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.thelittlenaruto.supportdesignexample"
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation ('com.android.support:appcompat-v7:22.2.1')
implementation ('com.android.support:design:22.2.1')
implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar'
}
型
以下是我迄今为止尝试过的:
- 将以下内容添加到我的模块build.gradle文件的android部分:
sourceSets {
main{
java{
exclude '**/META-INF/MANIFEST'
exclude '**/META-INF/MANIFEST.MF'
exclude 'META-INF/MANIFEST'
exclude 'META-INF/MANIFEST.MF'
exclude '!META-INF/MANIFEST.MF'
}
}
}
型
- 添加此内容:
sourceSets.main.res.filter.exclude 'META-INF/MANIFEST'
sourceSets.main.res.filter.exclude 'META-INF/MANIFEST.MF'
型
- 还有这个:
packagingOptions {
apply plugin: 'project-report'
exclude '**/META-INF/MANIFEST'
exclude '**/META-INF/MANIFEST.MF'
exclude 'META-INF/MANIFEST'
exclude 'META-INF/MANIFEST.MF'
exclude '!META-INF/MANIFEST.MF'
}
型
- 还有这个
packagingOptions {
pickFirst '**/META-INF/MANIFEST'
pickFirst '**/META-INF/MANIFEST.MF'
pickFirst 'META-INF/MANIFEST'
pickFirst 'META-INF/MANIFEST.MF'
pickFirst '!META-INF/MANIFEST.MF'
}
型
- 这一点:
aaptOptions {
ignoreAssetsPattern "!META-INF/MANIFEST.MF"
ignoreAssetsPattern "META-INF/MANIFEST.MF"
}
型
我想我已经在这个问题上试过了:How to exclude certain files from Android Studio gradle builds?
什么都不管用。
在搜索解决方案后,我认为问题在于我有重复的依赖项。所以我尝试了以下方法:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation ('com.android.support:appcompat-v7:22.2.1'){
exclude module: 'support-v4'
}
implementation ('com.android.support:design:22.2.1')
implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar'
}
型
还有这个
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation ('com.android.support:design:22.2.1'){
exclude module: 'support-v7'
}
implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar'
}
型
我仍然得到同样的错误。
我做错了什么?
6条答案
按热度按时间ut6juiuv1#
正如Rajen Raiyarela所说,转到文件->项目结构->项目->Android Gradle插件版本,并将其从3.5.2降级到3.5.1。
5ktev3wc2#
设置项目依赖为:
字符串
或最新的一个。
注意:通过这样做,我的问题已经解决了。
rkue9o1l3#
出现此问题是因为存在重复的依赖项。
检查Gradle应用中的多个依赖项。
nzk0hqpo4#
要么打包一次,要么根本不打包:
字符串
j2cgzkjk5#
正如
@rubo77
所说,经过我的确认:*最新解决方案
3.5.2
到3.5.3
3.5.2
到3.5.4
3.5.2
降级到3.5.1
我的选择是:从
3.5.2
升级到3.5.4
build.gradle
:字符串
的数据
c7rzv4ha6#
我在Android Studio Giraffe中遇到了同样的问题,
我删除
Build
文件夹并重建将为我解决问题。转到项目视图->构建
x1c 0d1x的数据