jitsi / jitsi-meet-flutter-sdk

Jitsi Meet plugin for Flutter
Apache License 2.0
31 stars 23 forks source link

Namespace for Gradle / Android #53

Open martin-bertele opened 1 month ago

martin-bertele commented 1 month ago

Trying to build with Android Studio:

A problem occurred configuring project ':jitsi_meet_flutter_sdk'.

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.

Other packages had this as well, e.g. in the inappview a version upgrade fixed this

https://github.com/pichillilorenzo/flutter_inappwebview/issues/1975

martin-bertele commented 1 month ago

Here is a workaround

So I guess package-internally the namespace could be set and devs will not run into the error, at the same time the workaround fixes it already.

add to your top-level build.gradle

allprojects {
    repositories {
        google()
        mavenCentral()
    }
    // This code is where all the magic happens and fixes the error.
    subprojects {
        afterEvaluate { project ->
            if (project.hasProperty('android')) {
                project.android {
                    if (namespace == null) {
                        namespace project.group
                    }
                }
            }
        }
    }
    // This code is where all the magic happens and fixes the error.
}
saghul commented 1 month ago

Thanks for sharing! Happy to take a PR fixing this for good in the project, if you're up for it.