我有一个多模块项目。在将Gradle更新为5.4.1
并将Android gradle插件更新为3.5.1
版本之后,我开始出现以下错误:
Execution failed for task ':Android.OTT.Framework:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'AndroidManifest.xml'
这是此模块的build.gradle
:
buildscript {
rootProject.ext {
support_version = '28.0.0'
retrofit_version = '2.6.0'
kodein_version = '6.2.1'
butterknife_version = '9.0.0'
joda_time_version = '2.10.2'
rxjava_version = '2.2.10'
rxandroid_version = '2.1.1'
nanohttpd_version = '2.3.1'
gson_version = '2.8.5'
okio_version = '2.2.2'
annimon_stream_version = '1.2.1'
leak_canary_version = '1.6.3'
ok_http_version = '3.12.1'
lifecycle_version = '1.1.1'
mockito_version = '2.28.2'
mockito_kotlin_version = '2.1.0'
kluent_version = '1.41'
}
repositories {
google()
maven { url 'https://maven.fabric.io/public' }
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.+'
classpath "com.jakewharton:butterknife-gradle-plugin:$butterknife_version"
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'
apply plugin: 'com.jakewharton.butterknife'
androidExtensions {
experimental = true
}
repositories {
google()
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/deltatre/exoplayer" }
}
allprojects {
repositories {
google()
flatDir {
dirs './divaLibs'
}
maven {
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
}
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
testOptions {
unitTests.returnDefaultValues = true
}
dataBinding {
enabled = true
}
}
realm {
syncEnabled = true
}
dependencies {
api project(':Android.OTT.OfflineVideo')
api project(':Android.OTT.D3Foundation')
// START DIVA PLAYER
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'divaLibs')
api files('divaLibs/divaandroidlib-release-4.7.2.aar')
implementation 'com.deltatre.android.exoplayer:exoplayer:2.9.5.1'
implementation 'com.github.davibe:MD360Player4Android:dev-SNAPSHOT'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.10.2'
api "com.google.code.gson:gson:$gson_version"
api "joda-time:joda-time:$joda_time_version" // needed also by Diva
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-ads:17.2.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
implementation 'com.google.android.gms:play-services-cast:16.2.0'
implementation 'com.google.android.gms:play-services-cast-framework:16.2.0'
implementation files('divaLibs/comscore-3.1502.26.jar')
implementation 'com.google.vr:sdk-videowidget:1.180.0'
//Firebase
api 'com.google.firebase:firebase-messaging:18.0.0'
api 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.android.gms:play-services-tagmanager:16.0.8'
// Urban Airship - FCM
api 'com.urbanairship.android:urbanairship-fcm:10.0.2'
// Support
api "com.android.support:design:$support_version"
api "com.android.support:cardview-v7:$support_version"
api "com.android.support:recyclerview-v7:$support_version"
api "com.android.support:support-v4:$support_version"
api "com.android.support:mediarouter-v7:$support_version"
api "com.android.support:appcompat-v7:$support_version"
api "com.android.support:support-v13:$support_version"
api "com.android.support:customtabs:$support_version"
api 'com.android.support.constraint:constraint-layout:1.1.3'
api 'com.android.support:multidex:1.0.3'
implementation "android.arch.lifecycle:viewmodel:$lifecycle_version"
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
// Analytics
api('com.crashlytics.sdk.android:answers:1.4.7@aar') {
transitive = true
}
api('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
transitive = true
}
// Ui
api 'me.relex:circleindicator:1.2.2@aar'
api 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.afollestad.material-dialogs:core:0.9.5.0'
// RETROFIT
api "com.squareup.retrofit2:retrofit:$retrofit_version"
api "com.squareup.retrofit2:converter-gson:$retrofit_version"
api "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
// ok http
implementation "com.squareup.okhttp3:okhttp:$ok_http_version"
implementation "com.squareup.okhttp3:logging-interceptor:$ok_http_version"
// Rx
api "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
api "io.reactivex.rxjava2:rxjava:$rxjava_version"
api 'com.jakewharton.rxbinding2:rxbinding:2.2.0'
// IoC
api "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
api "org.kodein.di:kodein-di-framework-android-support:$kodein_version"
// Usefull
api "com.annimon:stream:$annimon_stream_version"
api "com.jakewharton:butterknife:$butterknife_version"
kapt "com.jakewharton:butterknife-compiler:$butterknife_version"
api 'com.jakewharton.timber:timber:4.7.1'
implementation "com.squareup.okio:okio:$okio_version"
implementation "org.nanohttpd:nanohttpd:$nanohttpd_version"
implementation 'online.devliving:securedpreferencestore:0.7.4'
api 'com.jakewharton:process-phoenix:2.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// TV
api "com.android.support:leanback-v17:$support_version"
// Leak Canary
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leak_canary_version"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"
debugImplementation "com.squareup.leakcanary:leakcanary-support-fragment:$leak_canary_version"
testImplementation 'junit:junit:4.12'
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockito_kotlin_version"
testImplementation "org.mockito:mockito-inline:$mockito_version"
testImplementation "org.amshove.kluent:kluent-android:$kluent_version"
// Exomedia
implementation 'com.devbrackets.android:exomedia:4.3.0'
androidTestImplementation "org.mockito:mockito-android:$mockito_version"
}
这是项目的build.gradle
:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
maven { url 'https://maven.fabric.io/public' }
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'io.fabric.tools:gradle:1.+'
classpath 'io.realm:realm-gradle-plugin:5.11.0'
classpath 'com.google.gms:google-services:4.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle
模块的Android.OTT.OfflineVideo
:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
buildscript {
rootProject.ext {
jsoup_version = '1.12.1'
}
}
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
realm {
syncEnabled = true
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
implementation "com.annimon:stream:$annimon_stream_version"
implementation "com.google.code.gson:gson:$gson_version"
implementation "org.nanohttpd:nanohttpd:$nanohttpd_version"
implementation "org.jsoup:jsoup:$jsoup_version"
implementation "joda-time:joda-time:$joda_time_version"
implementation "com.android.support:support-annotations:$support_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
build.gradle
模块的Android.OTT.D3Foundation
:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:support-annotations:28.0.0"//todo
testImplementation 'junit:junit:4.12'
testImplementation 'org.amshove.kluent:kluent-android:1.41'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
testImplementation "org.mockito:mockito-inline:2.23.4"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
我看到了很多类似one的问题。但这不是我的情况,因为我不能只是忽略AndroidManifest.xml
文件。预先感谢!
答案 0 :(得分:2)
最终更新到AndroidX后,我收到了相同的错误。我被其他一些答案所暗示,就是将某些库恢复为它们的最后一个已知工作版本。最重要的是,android gradle插件。我的版本与您相同:
classpath 'com.android.tools.build:gradle:3.5.1'
我将其恢复为我的上一个稳定版本,对我来说是3.4.0
。
在同步项目,然后干净地重新构建它之后,编译器实际上提供了一条有意义的错误消息,指出我指向与我的AndroidManifest.xml
文件完全不相关的内容。换句话说,我得到了描述或链接到文件的实际问题。从那里开始,只需找出问题(通常用红色下划线标出)并加以解决就很容易。
因此,我建议您使用较早的android gradle插件版本(例如
)来解决问题 classpath 'com.android.tools.build:gradle:3.4.0'
然后在终于找到并解决该问题后还原(或保留旧的)。
答案 1 :(得分:0)
基于发生错误的位置-在mergeDebugJavaResource
gradle任务中以及关于多个Android清单的错误消息中,我可以假定问题在于有多个清单(例如,一个清单用于调试,一个清单用于生产) ),没有正确的manifest merging rules。
我多次遇到类似的问题,每次都是由于缺少适当的merge rules markers造成的。通常,我需要像这样在我的主清单中remove
或replace
一些值
<activity android:name="com.example.ActivityOne"
android:screenOrientation="portrait"
tools:remove="android:windowSoftInputMode">
<activity android:name="com.example.ActivityOne"
android:theme="@newtheme"
android:exported="true"
android:screenOrientation="portrait"
tools:replace="android:theme,android:exported">
它总是有效的。
然后,您可以inspect merged manifest查找不一致和错误并调整合并规则标记。
中的更多详细信息虽然这不是您问题的确切答案,但希望对您有所帮助。
答案 2 :(得分:0)
我试图重复您的问题。根据我的了解,这就是您在应用程序中用于视频功能的库Android.OTT.OfflineVideo和Android.OTT.D3Foundation的问题。所述库中包含的某些相同文件与您用于视频功能的库冲突。因此导致合并失败。
尝试以下逐步操作之一:
请尝试从您的应用程序中逐个删除媒体库(如下所述),然后尝试。然后,您将获得导致问题的库。检查该库,它可能包含与任何其他库相同的文件。然后从合并中排除该文件。
api project(':Android.OTT.OfflineVideo')
api project(':Android.OTT.D3Foundation')
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'divaLibs')
api files('divaLibs/divaandroidlib-release-4.7.2.aar')
implementation 'com.deltatre.android.exoplayer:exoplayer:2.9.5.1'
implementation 'com.github.davibe:MD360Player4Android:dev-SNAPSHOT'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.10.2'
// Exomedia
implementation 'com.devbrackets.android:exomedia:4.3.0'
请注意*,因为您知道这是合并的问题,并且由于我在复制问题方面有局限性,所以我建议的只是一些解决问题的方法。仍然希望“我知道这不是解决方案” :)谢谢。
答案 3 :(得分:0)
清理项目,然后使缓存无效并重新启动Studio,或者如果它不起作用,则对gradle版本进行降级,然后进行同步,同步完成后,将其更改回最新版本,然后再次同步。 希望它能解决您的问题
答案 4 :(得分:0)
我尝试了很多解决方案,最后得到了解决方案-
如果您正在使用gradle插件-
classpath 'com.android.tools.build:gradle:3.5.x'
您可能会遇到相同的问题。
然后我尝试将gradle插件降级为-
classpath 'com.android.tools.build:gradle:3.4.x'
或者我建议使用-
classpath 'com.android.tools.build:gradle:3.4.2'
这是gradle插件的最稳定版本。
然后File -> invalidate cache/restart
。清理您的项目并重建它。现在可以使用!