Skip to content

fix: remove package from AndroidManifest to align to newer build paradigms#2

Open
adityastic wants to merge 2 commits intokhalti:mainfrom
adityastic:patch-1
Open

fix: remove package from AndroidManifest to align to newer build paradigms#2
adityastic wants to merge 2 commits intokhalti:mainfrom
adityastic:patch-1

Conversation

@adityastic
Copy link
Copy Markdown

Failure with new AGP's

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':android_sms_consent'.
> 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: /Users/adityagupta/.pub-cache/hosted/pub.dev/android_sms_consent-1.0.2/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.

@lexprimost
Copy link
Copy Markdown

will this be merged please ? im getting same error

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':android_sms_consent'.

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.
  • 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.

@adityastic
Copy link
Copy Markdown
Author

@lexprimost you can always override android/build.gradle to add:

subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null) {
                    namespace project.group
                }
            }
        }
    }
}

Final gradle.build looks like this:

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null) {
                    namespace project.group
                }
            }
        }
    }
}
subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants