Skip to content

Gradle build error with Gradle 8.12 - namepace not specified #19

@norrisduncan

Description

@norrisduncan

I recently set up a new machine with a new version of Gradle and it is complaining that android_package_manager doesn't have a namespace specified in android_package_manager-0.7.1/android/build.gradle.

Very easy to fix, I just added the "namespace" entry below in your build.gradle file:

android {
    compileSdkVersion 34

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    defaultConfig {
        minSdkVersion 21
    }

    namespace = 'lab.neruno.android_package_manager'
}

The build error I get when I try flutter run:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':android_package_manager'.
> 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: /home/server/.pub-cache/hosted/pub.dev/android_package_manager-0.7.1/android/build.gradle. 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.

* 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 FAILED in 3s

Gradle is version 8.12,
android_package_manager is version 0.7.1,
flutter is version 3.32.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions