【问题标题】:Adding remote repo in Gradle - Manifest merger failed在 Gradle 中添加远程仓库 - 清单合并失败
【发布时间】:2014-10-28 10:52:03
【问题描述】:

我已在我的 android 库项目中添加了一个远程 maven 存储库,并在我的 build.gradle 中进行了以下更改:

apply plugin: android-library
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath com.android.tools.build:gradle:+
    }
}
apply plugin: maven
repositories {
    mavenCentral()
    maven {
        url https://mvn.xxx.com/content/repositories/releases/
        credentials {
            username xxxxxx
            password yyyyyy
        }
    }
}

现在它给了我一个明显的合并错误,说明 我的库包名称与远程 repo 的名称冲突。

Execution failed for task :spuul:processDebugTestManifest.
> java.lang.RuntimeException: Manifest merger failed : 
Attribute instrumentation#android.test.InstrumentationTestRunner@targetPackage
 value=(com.myLibrary.core.test) from manifestMerge1961318094990565159.xml:12:22
    is also present at com.remote.mavenrepo:1.0_7.64:16:9 value=(com.remote.mavenrepo)
    Suggestion: add 'tools:replace="android:targetPackage"' to <instrumentation> 
    element at manifestMerge1961318094990565159.xml:11:5 to override

不确定如何解决此问题。有没有办法跳过创建测试版本? 谢谢。

【问题讨论】:

    标签: android-studio android-gradle-plugin android-library android-build


    【解决方案1】:

    John Vuong 的响应是正确的,但包含一个小错误:XML 命名空间应该别名为“tools”,而不是“android”。

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.android.interpolatorplayground.tests"
      xmlns:tools="http://schemas.android.com/tools"
      android:versionCode="1"
      android:versionName="1.0">
    

    【讨论】:

      【解决方案2】:

      在 androidmanifest.xml 文件中, 添加

           <manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.example.android.interpolatorplayground.tests"
            **xmlns:android="http://schemas.android.com/tools"**
            android:versionCode="1"
            android:versionName="1.0">
      

      ....

          <instrumentation
              android:name="android.test.InstrumentationTestRunner"
              android:targetPackage="com.example.android.interpolatorplayground"
              **tools:replace="android:targetPackage"**
              android:label="Tests for com.example.android.interpolatorplayground" />
      

      .... 请参考这里Markers tools:replace

      【讨论】:

      • 正如@rydnr 所说,它是“xmlns:tools”而不是“:android”,请编辑
      猜你喜欢
      • 2018-02-18
      • 1970-01-01
      • 1970-01-01
      • 2018-03-11
      • 2018-03-15
      • 1970-01-01
      • 1970-01-01
      • 2013-02-07
      • 1970-01-01
      相关资源
      最近更新 更多