Why is the value for ${applicationName} not supplied after migrating my Flutter app to Android embedding v2?

1,129

Solution 1

I ran into this as well. In my case it was because I had set manifestPlaceholders the "usual" way, by assigning with = (as all examples seem to do):

In android/app/build.gradle:

android {
    ⋮
    defaultConfig {
        applicationId "com.example.my_app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        // This right here!
        manifestPlaceholders = [someKey: "@string/some_value"]
    }
    ⋮
}

It turns out that multidex support introduced the need to dynamically determine the application name, hence the ${applicationName} placeholder in the manifest.

That value is determined by the Flutter Gradle plugin here by means of manifestPlaceholders, so if you replace the value by reassigning it then you will run into this issue. The fix is simple: add your values to the existing ones with += like so:

android {
    ⋮
    defaultConfig {
        applicationId "com.example.my_app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        // Fixed now! Note the plus!
        manifestPlaceholders += [someKey: "@string/some_value"]
    }
    ⋮
}

Solution 2

I got the same error:

You need to add this to your build.gradle (YourFlutterProject/android/app/build.gradle)

buildTypes {
    release {
        manifestPlaceholders = [applicationName: "android.app.Application"]
    }

    debug {
        manifestPlaceholders = [applicationName: "android.app.Application"]
    }
    build{
        manifestPlaceholders = [applicationName: "android.app.Application"]
    }
}
Share:
1,129
Admin
Author by

Admin

Updated on December 16, 2022

Comments

  • Admin
    Admin over 1 year

    I tried to immigrate a deprecated flutter application, but after following the steps provided on github im getting this

    C:\Users\personal\AndroidStudioProjects\flash-chat-flutter\android\app\src\main\AndroidManifest.xml:10:9-42 Error:
        Attribute application@name at AndroidManifest.xml:10:9-42 requires a placeholder substitution but no value for <applicationName> is provided.
    C:\Users\personal\AndroidStudioProjects\flash-chat-flutter\android\app\src\debug\AndroidManifest.xml Error:
        Validation failed, exiting
    
  • Aaron
    Aaron over 2 years
    You do not need to do this; the framework does it for you. In fact the framework needs to do it dynamically in order to handle multidex scenarios properly. Per my answer, you simply need to avoid overwriting the values the framework provides.