Android 每次运行应用程序时,我都会出现渐变错误
我正在使用android项目,每次运行应用程序时都会出现以下类型的错误: 清单合并失败:属性application@appComponentFactory 值=(android.support.v4.app.CoreComponentFactory)来自 [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91也出现在 [androidx.core:core:1.0.0-alpha1]AndroidManifest.xml:22:18-86 值=(androidx.core.app.CoreComponentFactory)。建议:添加 'tools:replace=“android:appComponentFactory”'到元素 在AndroidManifest.xml:10:5-44:19进行重写 即使我试着按照它告诉我的方式去做,也有另一个错误 这是build.gradle文件:Android 每次运行应用程序时,我都会出现渐变错误,android,gradle,manifest,Android,Gradle,Manifest,我正在使用android项目,每次运行应用程序时都会出现以下类型的错误: 清单合并失败:属性application@appComponentFactory 值=(android.support.v4.app.CoreComponentFactory)来自 [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91也出现在 [androidx.core:core:1.0.0-alpha1]AndroidManif
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.community.jboss.visitingcard"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
//the intro library
implementation 'com.github.msayan:tutorial-view:v1.0.6'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation "com.android.support:preference-v7:28.0.0"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
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'
}
这是清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.community.jboss.visitingcard">
<!--
TODO: Add location/GPS access permissions
TODO: Change the Label of the Activities according to the Activity's
context
TODO: Change App Icon .i.e., ic_launcher
-->
<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">
<activity
android:name=".LoginActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".VisitingCard.VisitingCardActivity" />
<activity android:name=".IntroScreens.SliderActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- TODO: Add Google Maps API key here -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".Maps.MapsActivity"
android:label="@string/title_activity_maps"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<activity android:name=".VisitingCard.ViewVisitingCard" />
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings" />
<activity android:name=".IntroActivity"></activity>
</application>
</manifest>
在清单中添加以下行:
tools:replace="android:appComponentFactory"
像这样:
<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"
tools:replace="android:appComponentFactory>
//Your code here
</application>
您正在使用两个appcompat依赖项,一个来自support命名空间,另一个来自androidx命名空间。理想的解决方案是将您的项目完全移动到androidx并删除下面提到的依赖项
implementation 'com.android.support:appcompat-v7:28.0.0'
您可以使用稳定版本的andoid x appcompat库
androidx.appcompat:appcompat:1.0.0 instead of androidx.appcompat:appcompat:1.0.0-alpha1'
您似乎决定在项目中使用androidX,但将appCompat
与androidX
一起使用是不正确的。
如果您使用androidX的库,最好删除appCompat库。
如果您坚持在build.gradle
文件中使用androidX,请删除实现'com.android.support:appcompat-v7:28.0.0'
,或者删除androidX one,否则
有关错误的详细信息:
您可以打开“清单”文件并转到“合并”选项卡。在文件的底部,你可以看到什么是错误的 是的,当我尝试它时,它说清单合并失败,出现了多个错误,请参阅日志。您在清单中添加了这一行吗<代码>工具:replace=“android:appComponentFactory”
但我是否应该删除实现“com.android.support:design:28.0.0”以及实现“com.android.support:preference-v7:28.0.0”您是否部分迁移到了androidx。将com.android.support:preference-v7:28.0.0替换为这个androidx.preference:preference:1.0.0将com.android.support.design:28.0.0替换为com.google.android.material:material:1.0.0-rc01参考更多信息我用这些gradle构建了应用程序,但现在所有其他文件都出现错误