清单和构建错误

时间:2019-06-30 14:56:49

标签: android android-studio android-activity kotlin android-manifest

突然发现所有这些错误,所有构建错误 “清单合并失败,Android Studio中出现多个错误”

那是我不知道的时候通过android studio提出的替换建议

“清单合并失败:来自[com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91的属性application @ appComponentFactory value =(android.support.v4.app.CoreComponentFactory)     也存在于[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value =(androidx.core.app.CoreComponentFactory)。     建议:在AndroidManifest.xml:9:5-43:19的元素上添加'tools:replace =“ android:appComponentFactory”'以进行覆盖。“

那是清单

 <application

            android:allowBackup="true"
            android:icon="@drawable/messengered"
            android:label="@string/app_name"
            android:roundIcon="@drawable/messengered"
            android:supportsRtl="true"
            android:theme="@style/AppTheme"
            tools:ignore="GoogleAppIndexingWarning"
            >

        <activity android:name=".NewMessegesActivity">
            <meta-data android:name="android.support.PARENT_ACTIVITY"
                       android:value=".LatestMessagesActivity"/>
        </activity>

        <activity android:name=".LatestMessagesActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity android:name=".LoginActivity">
        </activity>

        <activity android:name=".RegisterActivity">
        </activity>

    </application>

这是应用gradle

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.xwray:groupie:2.3.0'

    implementation 'com.android.support:recyclerview-v7:28.+'
    implementation 'com.squareup.picasso:picasso:2.71828'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

我尝试了标记的解决方案后,出现编译错误,并通过将依赖项从“ android.support”更改为“ androidx.support”来解决了此问题

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.google.firebase:firebase-storage:18.0.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.xwray:groupie:2.3.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
} 

然后将布局重新分配给“ AppCompatActivity()”,因为出现错误,将在清单中对其进行修复

2 个答案:

答案 0 :(得分:0)

问题是您的构建同时使用了旧的com.android.support命名空间和新的androidx命名空间。

要完全解决此问题,谷歌创建了他们的“喷射器”工具,请参见StackOverflow/What is Jetifier,以获取更多信息以及使用方法。

答案 1 :(得分:-1)

您可以将这两行添加到您的清单文件

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

喜欢

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:replace="android:appComponentFactory"
    android:appComponentFactory="whateverString">

我希望它对您有用...