Android 添加CameraX gradle依赖项时清单合并失败
我正试图在一个全新的Android Studio项目中使用CameraX库,该项目基于官方: 我已将以下依赖项添加到我的(模块)build.gradle中:Android 添加CameraX gradle依赖项时清单合并失败,android,gradle,camera,android-gradle-plugin,android-camerax,Android,Gradle,Camera,Android Gradle Plugin,Android Camerax,我正试图在一个全新的Android Studio项目中使用CameraX库,该项目基于官方: 我已将以下依赖项添加到我的(模块)build.gradle中: implementation "androidx.camera:camera-core:1.0.0-alpha01" implementation "androidx.camera:camera-camera2:1.0.0-alpha01" apply plugin: 'com.android.application'
implementation "androidx.camera:camera-core:1.0.0-alpha01"
implementation "androidx.camera:camera-camera2:1.0.0-alpha01"
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "simplediary.raouf.camerapoc"
minSdkVersion 21
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "androidx.camera:camera-core:1.0.0-alpha01"
implementation "androidx.camera:camera-camera2:1.0.0-alpha01"
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'
}
我的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="simplediary.raouf.camerapoc">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
因此,在AndroidManifest.xml中的“合并清单”下,我现在看到了以下错误:
Error: tools:replace specified at line:9 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 8 Error: Validation failed, exiting app main manifest (this file)
我怎样才能避开这个问题?Full build.gradle:
implementation "androidx.camera:camera-core:1.0.0-alpha01"
implementation "androidx.camera:camera-camera2:1.0.0-alpha01"
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "simplediary.raouf.camerapoc"
minSdkVersion 21
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "androidx.camera:camera-core:1.0.0-alpha01"
implementation "androidx.camera:camera-camera2:1.0.0-alpha01"
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'
}
谢谢你的帮助 您必须迁移到
AndroidX
库:
以下是步骤:
1/进入“重构”
2/在下拉菜单中选择“迁移到AndroidX”
3/确保保留备份(通过版本控制或选中保留备份复选框)
4/按照安装向导进行操作
5/完成项目清理和重建后
您需要迁移到AndroidX工件。检查这里:在app->refactor下,我只看到Migrate to AppCompat和Migrate。它们中没有任何一个引用AndroidX,我也遇到了同样的问题。@如果迁移过程中有任何Maven依赖项未迁移到AndroidX命名空间或任何其他问题,eyesenberg将使用
重构
@eyesenberg,尝试手动覆盖它,方法是转到gradle.properties
文件,然后将它们添加到以下行:android.useAndroidX=true
和android.enableJetifier=true
仍然存在相同的问题。我看不到重构下的AndroidX(但添加了gradle属性)。然而,我的Android Studio可能已经一年没有更新了,所以要更新它now@eyesenberg是的,更新为肯定会解决问题