Flutter Firebase 集成构建失败,出现:app:processDebugManifest
Flutter Firebase Integration Build failed with :app:processDebugManifest
我刚开始使用 firebase 集成。
在完成由 firebase 指导的基本步骤后 运行 项目时出现错误。
我的应用程序build.gradle
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的androidbuild.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.rental.asp.rental_actual"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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.firebase:firebase-analytics:17.2.0'
}
apply plugin: 'com.google.gms.google-services'
当我构建时,这是输出
21:30:55.498 1 info flutter.tools Launching lib\main.dart on SM N975U1 in debug mode...
21:30:55.505 2 info flutter.tools Initializing gradle...
21:30:56.251 3 info flutter.tools Resolving dependencies...
21:31:02.480 4 info flutter.tools Running Gradle task 'assembleDebug'...
21:31:05.312 5 info flutter.tools registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
21:31:05.313 6 info flutter.tools registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
21:31:05.313 7 info flutter.tools registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
21:31:12.464 8 info flutter.tools H:\Rental\rental\rental_actual\android\app\src\debug\AndroidManifest.xml:22:18-91 Error:
21:31:12.464 9 info flutter.tools Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
21:31:12.464 10 info flutter.tools is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
21:31:12.464 11 info flutter.tools
21:31:12.464 12 info flutter.tools Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:9:5-32:19 to override.
21:31:12.464 13 info flutter.tools
21:31:12.464 14 info flutter.tools FAILURE: Build failed with an exception.
21:31:12.464 15 info flutter.tools
21:31:12.464 16 info flutter.tools * What went wrong:
21:31:12.465 17 info flutter.tools Execution failed for task ':app:processDebugManifest'.
21:31:12.465 18 info flutter.tools > 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
21:31:12.465 19 info flutter.tools is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
21:31:12.465 20 info flutter.tools Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:9:5-32:19 to override.
21:31:12.465 21 info flutter.tools
21:31:12.465 22 info flutter.tools * Try:
21:31:12.465 23 info flutter.tools Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
21:31:12.465 24 info flutter.tools
21:31:12.466 25 info flutter.tools * Get more help at https://help.gradle.org
21:31:12.466 26 info flutter.tools
21:31:12.466 27 info flutter.tools BUILD FAILED in 9s
也在我的android/build.gradle第一行
def localProperties = new Properties()
&
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
获得'Cannot resolve symbol'
只需在您的 android 包的 "gradle.properties" 中添加以下两行,即可将 AndroidX 添加到您的项目中文件。
android.useAndroidX=true
android.enableJetifier=true
完成。
此外,我会建议您使用1.3以上的kotlin版本,例如1.3.31等。这是您的选择。
我刚开始使用 firebase 集成。
在完成由 firebase 指导的基本步骤后 运行 项目时出现错误。
我的应用程序build.gradle
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的androidbuild.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.rental.asp.rental_actual"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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.firebase:firebase-analytics:17.2.0'
}
apply plugin: 'com.google.gms.google-services'
当我构建时,这是输出
21:30:55.498 1 info flutter.tools Launching lib\main.dart on SM N975U1 in debug mode...
21:30:55.505 2 info flutter.tools Initializing gradle...
21:30:56.251 3 info flutter.tools Resolving dependencies...
21:31:02.480 4 info flutter.tools Running Gradle task 'assembleDebug'...
21:31:05.312 5 info flutter.tools registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
21:31:05.313 6 info flutter.tools registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
21:31:05.313 7 info flutter.tools registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
21:31:12.464 8 info flutter.tools H:\Rental\rental\rental_actual\android\app\src\debug\AndroidManifest.xml:22:18-91 Error:
21:31:12.464 9 info flutter.tools Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
21:31:12.464 10 info flutter.tools is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
21:31:12.464 11 info flutter.tools
21:31:12.464 12 info flutter.tools Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:9:5-32:19 to override.
21:31:12.464 13 info flutter.tools
21:31:12.464 14 info flutter.tools FAILURE: Build failed with an exception.
21:31:12.464 15 info flutter.tools
21:31:12.464 16 info flutter.tools * What went wrong:
21:31:12.465 17 info flutter.tools Execution failed for task ':app:processDebugManifest'.
21:31:12.465 18 info flutter.tools > 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
21:31:12.465 19 info flutter.tools is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
21:31:12.465 20 info flutter.tools Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:9:5-32:19 to override.
21:31:12.465 21 info flutter.tools
21:31:12.465 22 info flutter.tools * Try:
21:31:12.465 23 info flutter.tools Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
21:31:12.465 24 info flutter.tools
21:31:12.466 25 info flutter.tools * Get more help at https://help.gradle.org
21:31:12.466 26 info flutter.tools
21:31:12.466 27 info flutter.tools BUILD FAILED in 9s
也在我的android/build.gradle第一行
def localProperties = new Properties()
&
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
获得'Cannot resolve symbol'
只需在您的 android 包的 "gradle.properties" 中添加以下两行,即可将 AndroidX 添加到您的项目中文件。
android.useAndroidX=true
android.enableJetifier=true
完成。
此外,我会建议您使用1.3以上的kotlin版本,例如1.3.31等。这是您的选择。