我想使用最新的android studio,并且导入了旧版本代码 并在更新后更新android studio我遇到以下错误 gradle android studio更新后
Manifest merger failed : Attribute application@appComponentFactory
value=(android.support.v4.app.CoreComponentFactory) from
[com.android.support:support-compat:28.0.0]
AndroidManifest.xml:22:18-91 is also present at
[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86
value=(androidx.core.app.CoreComponentFactory). Suggestion: add
'tools:replace="android:appComponentFactory"' to <application> element
at AndroidManifest.xml:5:1-38:15 to override.
我在清单中添加了上述错误中提到的一个标签
<?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.digiskillslms.app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:replace="android:appComponentFactory"
android:theme="@style/AppTheme">
但是在此之后发生另一个错误,请我解决 我从前一天就被卡住了这个错误
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugManifest'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
我的gradle文件是
compileSdkVersion 28
defaultConfig {
applicationId "app.digiskills.com.digiskillsapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout: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'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'pub.devrel:easypermissions:0.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation('com.google.api-client:google-api-client-android:1.25.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-youtube:v3-rev205-1.25.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation 'com.google.dagger:dagger:2.10'
// implementation 'com.google.dagger:dagger-compiler:2.10'
implementation 'com.android.support:design:28.0.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
implementation "com.mikepenz:materialdrawer:6.1.0"
答案 0 :(得分:1)
最后,我通过替换此问题解决了
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
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'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
}
答案 1 :(得分:0)
答案 2 :(得分:0)
在tools:replace="android:appComponentFactory"
上添加AndoridManifest.xml
也不能解决我的问题。
与mentioned here一样,在这里(Getting Started),您可能需要转到:
Refactor -> Migrate to Android X
然后,就可以使用了。
请注意,您还需要在xml端更改xml代码。
例如(那些应该以{{1}}开头):
androidx
答案 3 :(得分:0)
将android:appComponentFactory
添加到您的清单
<application
android:appComponentFactory="android.support.v4.app.CoreComponentFactory"
tools:replace="android:appComponentFactory">