【问题标题】:Attribute application@name at AndroidManifest.xml:5:9-42 requires a placeholder substitution but no value for <applicationName> is provided. - FlutterAndroidManifest.xml:5:9-42 中的属性 application@name 需要占位符替换,但未提供 <applicationName> 的值。 - 颤振
【发布时间】:2023-02-04 20:22:57
【问题描述】:

运行项目时出现以下错误。

Launching lib\main.dart on SM N970F in debug mode...
lib\main.dart:1
Parameter format not correct -
D:\CIIT GUIDE\Flutter\Apps\multi_delivery_app\android\app\src\main\AndroidManifest.xml:5:9-42 Error:
    Attribute application@name at AndroidManifest.xml:5:9-42 requires a placeholder substitution but no value for <applicationName> is provided.
D:\CIIT GUIDE\Flutter\Apps\multi_delivery_app\android\app\src\debug\AndroidManifest.xml Error:
    Validation failed, exiting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed with multiple errors, see logs

* Try:
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.

* Get more help at https://help.gradle.org

这就是 build.gradleandroid/app 中的样子。


android {
    compileSdkVersion 29
    // buildToolsVersion '26.0.3'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.example.multi_delivery_app"
        minSdkVersion 28
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        // Stackoverflow solution
        manifestPlaceholders = [appAuthRedirectScheme: "com.example.multi_delivery_app"]   
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }

我在网上找到了几个与 react-native 有关的解决方案,但没有任何效果。以下是我尝试过的解决方案的链接。 https://stackoverflow.com/a/52178888/7290043

【问题讨论】:

  • 如果您的 build.gradle 没有覆盖 manifestPlaceholders 而您仍然面临这个问题,将 Flutter 升级到 2.10.2(运行 flutter upgrade)将解决问题,因为旧的 Flutter SDK 没有注入 manifestPlaceholders,Flutter v2 嵌入依靠。

标签: android flutter dart android-manifest


【解决方案1】:

您可以将 appAuthRedirectScheme 属性添加到 manifestPlaceholders 而不是替换整个数组,方法是使用 += 而不是 =

例子 :

defaultConfig {
    ...
    manifestPlaceholders += [appAuthRedirectScheme: "com.example.multi_delivery_app"]
}

【讨论】:

  • 这是方法
  • 对我来说,这个简单的解决方案就成功了。我的配置➜ flutterdemo flutter --version Flutter 3.3.10 • channel stable • git@github.com:flutter/flutter.git Framework • revision 135454af32 (5 weeks ago) • 2022-12-15 07:36:55 -0800 Engine • revision 3316dd8728 Tools • Dart 2.18.6 • DevTools 2.15.0
【解决方案2】:

我认为在 build.gradle 中应该添加带有 Android 应用程序类全名的 applicationName 键(它扩展了 FlutterApplication

例如:

defaultConfig {
    ...
    manifestPlaceholders = [appAuthRedirectScheme: "com.example.multi_delivery_app", 
                            applicationName: "com.example.multi_delivery_app.Application"]
}

【讨论】:

    【解决方案3】:

    将此代码添加到位于 androidppsrcmainAndroidManifest.xml 中的 AndroidManifest.xml 文件中

    android:name="${applicationName}"

    例子:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.your_app_name">
    
       <application
            android:label="Your App Name"
            android:name="${applicationName}"
            android:icon="@mipmap/ic_launcher">
            <activity
                android:name=".MainActivity"
                android:exported="true"
                android:launchMode="singleTop"
                android:theme="@style/LaunchTheme"
                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
                android:hardwareAccelerated="true"
                android:windowSoftInputMode="adjustResize">
                
                <meta-data
                  android:name="io.flutter.embedding.android.NormalTheme"
                  android:resource="@style/NormalTheme"
                  />
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
            </activity>
            <meta-data
                android:name="flutterEmbedding"
                android:value="2" />
        </application>
    </manifest>
    

    【讨论】:

      【解决方案4】:

      在 AndroidManifest.xml 中

       android:name="${applicationName}" // change application to applicationName
       android:label="olt"
       android:icon="@mipmap/launcher_icon">```
      

      【讨论】:

      • 正如目前所写,您的答案尚不清楚。请edit 添加更多详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写出好的答案的信息in the help center
      【解决方案5】:

      我遇到过这样的问题。
      我发现清单文件中没有定义该包。
      如图所示

      【讨论】:

        【解决方案6】:

        只需添加这一行你的应用级 build.gradle

        buildTypes {
                debug{
                    manifestPlaceholders = [consumerAppId:"com.rsp.liftprojectsipclient"]
        ...
                }
                release {
                    manifestPlaceholders = [consumerAppId:"com.rsp.liftprojectsipclient"]
        ...
            }
        

        【讨论】:

        • 将 id 替换为您的应用程序 ID
        猜你喜欢
        • 1970-01-01
        • 2019-02-10
        • 2016-09-18
        • 2022-10-06
        • 1970-01-01
        • 2017-12-17
        • 1970-01-01
        • 2014-03-10
        • 2013-11-15
        相关资源
        最近更新 更多