skip to Main Content

Suddenly I’m getting the namespace error in my flutter project.

  • What went wrong:
    A problem occurred evaluating root project ‘android’.

A problem occurred configuring project ‘:app’.
Could not create an instance of type com.android.build.api.variant.impl.ApplicationVariantImpl.
> Namespace not specified. Specify a namespace in the module’s build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

    If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.
enter code here

enter image description here

Thank you in advance for the help.

2

Answers


  1. Read what the error tells you.

    In newer versions of AGP, the declaration of namespace/package was moved from AndroidManifest and to build script.

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        <!-- package="com.example.app" POOF! -->
    >
    

    and

    android {
        namespace = "com.example.app"
    
    Login or Signup to reply.
  2. compileOptions
    {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    
    kotlinOptions
    {
        jvmTarget = '17'
    }
    

    Upgrade the Java version to 17 in the app-level build.gradle file. This adjustment should resolve the issue in my scenario.[1]: https://phpout.com/wp-content/uploads/2024/02/8zRn6.png

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search