问题描述
我已经克隆了github存储库,因为我想研究代码,但是当我尝试在Android Studio中构建它时,遇到了一些麻烦.添加google maven存储库(如Android Studio提示)并更新Gradle插件版本和成绩版本(分别为3.5.2和5.4.1)后,由于以下错误,构建失败:
I've cloned a github repository because I wanted to study the code, but when I tried to build it in Android Studio, I ran into some trouble.After adding the google maven repository (as prompted by Android Studio) and updating both the Gradle Plugin Version and the Grade Version (to 3.5.2 and to 5.4.1, respectively), the build fails because of the following error:
更具体地说:
这是我的项目级别的build.gradle文件:
Here is my project level build.gradle file:
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文件(尝试任何操作之前):
Here's my module build.gradle file (before trying anything):
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'
}
这是我到目前为止尝试过的:
Here's what I've tried so far:
- 将以下内容添加到我的模块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"
}
我想我在这个问题上几乎尝试了所有事情:如何从Android Studio gradle版本中排除某些文件?/a>
I think I've tried mostly everything in this question:How to exclude certain files from Android Studio gradle builds?
什么都没做.
在寻找解决方案之后,我认为问题在于我有重复的依赖项.因此,我尝试了以下方法:
After searching for a solution, I think the problem is that I have duplicated dependencies. So I've tried the following:
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'
}
我仍然遇到相同的错误.
I still get the same error.
任何人都可以告诉我我做错了什么吗?谢谢您的期待. :)
Could anyone please tell me what I'm doing wrong?Thank you in anticipation. :)
推荐答案
如 Rajen Raiyarela 所述,请转到File-> Project Structure-> Project-> Android Gradle插件版本并将其从3.5.2降级到3.5.1.
As Rajen Raiyarela said, go to File->Project Structure->Project->Android Gradle Plugin Version and downgrade it from 3.5.2 to 3.5.1.
这篇关于Gradle重复项输入错误:META-INF/MANIFEST.MF(或如何从jar中删除文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!