androidflutterdartgradleflutter-inappwebview

A problem occurred configuring project ':flutter_inappwebview'


MY AGP is 8.1.4 and flutter version is 3.16.5 FAILURE: Build failed with an exception.

=> What went wrong: **A problem occurred configuring project ':flutter_inappwebview'. **> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.

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.

I want add package inappwebView to my app


Solution

  • What does this mean?

    In newer versions of the Android Gradle Plugin and Gradle, the namespace was shifted from the AndroidManifest.xml to app/build.gradle. Generally, this means the following:

    In all three AndroidManifest.xml files (main, debug, profile), remove the package attribute:

    <!-- This is how it should look like: -->
    
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <!-- YOUR CONTENT HERE -->
    </manifest>
    

    In app/build.gradle, add this line:

    android {
        namespace "com.example.yourpackage"
        ...
    }
    

    However, this requires all modules in your project to add the namespace. It seems like your package does not have this attribute yet.

    How to fix this error?

    1. Define the namespace globally as descibed in this SO answer
    2. (recommended) Downgrade Gradle and wait for your packages to migrate to newer versions