com.android.manifmerger.ManifestMerger2$MergeFailureException

问题描述 投票:0回答:2

我最近正在构建一个 Flutter 项目。我可以在 iOS 模拟器上运行它,但不能在 Android 模拟器上运行。当我尝试在 Android 上运行它时,出现错误:

FAILURE:构建失败并出现异常。

  • 出了什么问题: 任务“:app:processDebugManifest”执行失败。

com.android.manifmerger.ManifestMerger2$MergeFailureException: org.xml.sax.SAXParseException;行号:9;列数:2;文档中根元素后面的标记必须格式正确。

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.Meucci">
    <!-- Flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>

<application tools:node="replace">

</application>

构建.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 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 31

    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.example.Meucci"
        minSdkVersion 23
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    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"
}

gradle.属性

org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true

有人可以帮忙吗?非常感谢。

android flutter gradle
2个回答
0
投票
<application tools:node="replace"></application>

应该在

<manifest>
内。但看的时候。您可能可以删除这些行,因为它没有做太多


0
投票

xmlns:工具=“http://schemas.android.com/tools”

添加到清单中

© www.soinside.com 2019 - 2024. All rights reserved.