ukasz123 / soundpool

Soundpool plugin for Flutter
88 stars 63 forks source link

Namespace not specified. Specify a namespace in the module's build file #121

Closed MrCsabaToth closed 10 months ago

MrCsabaToth commented 11 months ago

Steps to Reproduce

I depend on soundpool 2.3.0 in my app. I just tried to upgrade the Android side of the Flutter app to AGP 8.0+ (to be precise it's AGP 8.1 now), because Android Studio brings up the upgrade assistant for the last half year about this. The upgrade fails because some of the plugins don't have the namespace in their build.gradle. On of the failing plugins is the soundpool.

The build error message

A problem occurred configuring project ':soundpool'.
> 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.

Code sample

Current build.gradle:

android {
    compileSdkVersion 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    defaultConfig {
        minSdkVersion 16
    }
    lintOptions {
        disable 'InvalidPackage'
    }
}

Expected (the way it is handled in Flutter Community plugins, along with he removal of the namespace from the AndroidManifest.xml):

android {
    // Conditional for compatibility with AGP <4.2.
    if (project.android.hasProperty("namespace")) {
        namespace 'pl.ukaszapps.soundpool'
    }

    compileSdkVersion 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    defaultConfig {
        minSdkVersion 16
    }
    lintOptions {
        disable 'InvalidPackage'
    }
}

Details


MrCsabaToth commented 10 months ago

Should I craft a PR or the project is dead?

ukasz123 commented 10 months ago

Almost. But the PR would be helpful.

MrCsabaToth commented 10 months ago

Done!