【问题标题】:Getting Build Error after upgrading to Android Studio 3.2.1升级到 Android Studio 3.2.1 后出现构建错误
【发布时间】:2019-05-04 03:27:32
【问题描述】:

我的构建失败并出现此错误 - 清单合并失败并出现多个错误,请参阅日志

合并错误它显示为 -

错误:AndroidManifest.xml:23:9-51 应用程序主清单(此文件)第 22 行的元素元数据中缺少“名称”键属性 错误:工具:在第 23 行为属性 android:value 指定了替换,但没有指定新值应用程序主清单(此文件),第 22 行 错误:验证失败,退出应用程序主清单(此文件)

AndroidManifest.xml - 下面是清单文件中显示错误的一小段。

<application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <meta-data tools:replace="android:value"/>
        <activity ....

Build.Gradle 文件下面的小段——

android {
    compileSdkVersion 26
    buildToolsVersion '28.0.3'
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 26
}
        dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support:design:26.1.0'
        implementation 'com.google.android.gms:play-services-ads:17.1.1'
        implementation 'com.google.android.gms:play-services-analytics:16.0.5'
        testImplementation 'junit:junit:4.12'
    }

【问题讨论】:

  • 检查过其他未指定的错误吗?
  • 这看起来像是个错误:&lt;meta-data tools:replace="android:value"/&gt;
  • 我删除了这段代码 现在它正在工作。不记得为什么我之前添加了这个。感谢@TheWanderer 指出这一点。
  • 将 gradle 版本从 4.2 更新到 4.6。它会解决问题

标签: android android-studio build.gradle android-manifest


【解决方案1】:

Android Studio 3.2.1

只需在build.gradle 的根级别添加google()

buildscript {
    repositories {
        google() //  <--here
        jcenter()
    }
 }

allprojects {
    repositories {
        google() //  <-- here
        jcenter()
    }
}

现在看看魔术 - 错误消失了...... :)

【讨论】:

  • 这个答案与错误信息最不匹配。我对另一个投了赞成票。
【解决方案2】:

删除这个:

<meta-data tools:replace="android:value"/>

它似乎没有做任何事情,这是你的错误的原因。

【讨论】:

    猜你喜欢
    • 2019-03-18
    • 2015-11-12
    • 2019-05-23
    • 2016-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-28
    • 2018-09-10
    相关资源
    最近更新 更多