LeGoffMael / insta_assets_picker

An image (and videos) picker similar with Instagram, supports multi picking, crop and aspect ratio.
https://pub.dev/packages/insta_assets_picker
MIT License
79 stars 34 forks source link

Build Error with AGP 8.0+: Namespace not specified #38

Closed aymanalhalali closed 3 weeks ago

aymanalhalali commented 5 months ago

Hello,

I've recently updated my project's Flutter version and the Android Gradle Plugin to the latest version, and after doing so, I encountered a build issue with the insta_assets_picker package. The error occurs when trying to configure the project:

A problem occurred configuring project ':insta_assets_picker'.

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.

It seems that the newer version of AGP requires a namespace declaration in the module's build.gradle file. Here is the environment in which the error occurred:

According to the Android documentation on namespaces, this is a new requirement starting with AGP 8.0.

Could you please look into this issue? If it's a matter of updating the package to support the latest AGP requirements, an update would be greatly appreciated. I rely on insta_assets_picker for my project, and this build issue is a blocker for me.

Thank you for your work on this package and for any assistance you can provide.

Best regards, Ayman

LeGoffMael commented 5 months ago

Hum, as you can see in the repository there is no android configuration in this package, so I am not sure how this issue could occurs from this package. Did you fixed your issue ?

aymanalhalali commented 5 months ago

I was only able to solve it by using previous versions rather than upgrading to 8.0:

AngeloAvv commented 4 months ago

Hey @LeGoffMael , I'm having the same problem. The incriminated library should be insta_assets_crop, which is a direct dependency of insta_assets_picker.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':insta_assets_crop'.
> 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.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Failed to query the value of property 'buildFlowServiceProperty'.
> Could not isolate value org.jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@ea90cb7 of type BuildFlowService.Parameters
   > A problem occurred configuring project ':insta_assets_crop'.
      > 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.
> Get more help at https://help.gradle.org.
==============================================================================

BUILD FAILED in 780ms
Error: Gradle task assembleDebug failed with exit code 1

I can open an issue here if you want

inludese commented 4 months ago

Simply add this to top level build.gradle into allprojects section

subprojects {
        afterEvaluate { project ->
            if (project.hasProperty('android')) {
                project.android {
                    if (namespace == null) {
                        namespace project.group
                    }
                }
            }
        }
    }
AngeloAvv commented 4 months ago

@inludese but this is not a fix, is a workaround

LeGoffMael commented 3 weeks ago

Thank you so much for your insights @AngeloAvv, I released a new insta_assets_crop version with the fix. This issue should be fixed in the new 2.3.1 version !