【问题标题】:Android auto manifest merger failed: attribute is also present atAndroid 自动清单合并失败:属性也存在于
【发布时间】:2022-08-03 01:15:02
【问题描述】:

我目前正在尝试构建一个 hello world 应用程序作为我的第一个 android 自动应用程序。早些时候,当我尝试运行该应用程序时,它给了我一些 minSdk 错误,我设法解决了这个问题。现在,当我尝试运行它时,它给了我这个错误:

Manifest merger failed : Attribute meta-data#androidx.car.app.CarAppMetadataHolderService.CAR_HARDWARE_MANAGER@value value=(androidx.car.app.hardware.ProjectedCarHardwareManager) from [androidx.car.app:app-projected:1.1.0] AndroidManifest.xml:34:17-86
    is also present at [androidx.car.app:app-automotive:1.1.0] AndroidManifest.xml:44:17-87 value=(androidx.car.app.hardware.AutomotiveCarHardwareManager).
    Suggestion: add \'tools:replace=\"android:value\"\' to <meta-data> element at AndroidManifest.xml to override.

我一直在尝试按照说明 here 来编辑清单文件,根据说明一切看起来都很好。

这是 AndroidManifest.xml:

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"
    xmlns:tools=\"http://schemas.android.com/tools\"
    package=\"com.smartherd.helloworld\">

    <uses-feature
        android:name=\"android.hardware.type.automotive\"
        android:required=\"true\" />

    <application
        android:allowBackup=\"true\"
        android:appCategory=\"audio\"
        android:icon=\"@mipmap/ic_launcher\"
        android:label=\"@string/app_name\"
        android:roundIcon=\"@mipmap/ic_launcher_round\"
        android:supportsRtl=\"true\"
        android:theme=\"@style/Theme.HelloWorld\">

        <service
        android:name=\".HelloWorldService\"
        android:exported=\"true\">
            <intent-filter>
                <action android:name=\"androidx.car.app.CarAppService\"/>
                <category android:name=\"androidx.car.app.category.POI\"/>
            </intent-filter>
        </service>

        <meta-data
            android:name=\"androidx.car.app.minCarApiLevel\"
            android:value=\"1\"/>

    </application>



</manifest>

构建.gradle:

plugins {
    id \'com.android.application\'
    id \'org.jetbrains.kotlin.android\'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId \"com.smartherd.helloworld\"
        minSdk 29
        targetSdk 32
        versionCode 1
        versionName \"1.0\"

        testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile(\'proguard-android-optimize.txt\'), \'proguard-rules.pro\'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation(\"androidx.car.app:app:1.1.0\")
    // For Android Auto specific functionality
    implementation(\"androidx.car.app:app-projected:1.1.0\")
    // For Android Automotive specific functionality
    implementation(\"androidx.car.app:app-automotive:1.1.0\")
    // For testing
    testImplementation(\"androidx.car.app:app-testing:1.2.0-rc01\")
    implementation \'androidx.core:core-ktx:1.7.0\'
    implementation \'androidx.appcompat:appcompat:1.4.2\'
    testImplementation \'junit:junit:4.13.2\'
    androidTestImplementation \'androidx.test.ext:junit:1.1.3\'
    androidTestImplementation \'androidx.test.espresso:espresso-core:3.4.0\'
}

    标签: android manifest android-auto


    【解决方案1】:

    由于您在清单中以 Android Automotive 为目标,因此您可以在 gradle 文件中摆脱以下依赖项:

        implementation("androidx.car.app:app-projected:1.1.0")
    

    那应该可以解决您遇到的冲突。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多