Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android gradle 8.x] Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl. #993

Open
muhsinPlanetMedia opened this issue Nov 26, 2024 · 3 comments
Labels
android This issue is specific to the Android Platform.

Comments

@muhsinPlanetMedia
Copy link

Launching lib\main.dart on moto g45 5G in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

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

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 3s
Error: Gradle task assembleDebug failed with exit code 1

@Liuwe1Ye
Copy link

Do you have any solution for this problem? I meet same problem when use flutter with unity.

@timbotimbo
Copy link
Collaborator

timbotimbo commented Dec 2, 2024

The relevant part of your error is

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

When using Gradle 8.x you are required to have a namespace definition in your build.gradle files to compile the project.

Current status

  • The plugin flutter_unity_widget plugin on pub.dev (2022.21) doesn't have this yet, but the master branch here does.
    (I don't have permission to publish pub.dev updates)
  • Unity 2022.3 does not include this by default, Unity 6 does.

Workaround

So if you import the plugin in your pubspec.yaml from a git url instead of pub.dev, it should be fixed on the plugin side.

flutter_unity_widget:
    git:
      url: https://github.com/juicycleff/flutter-unity-view-widget.git
      ref: master # branch name or commit hash

For Unity, use the build.cs script from the master branch, or add the code from the commit linked above to your build.cs script.

Another alternative would be to try the experimental Unity 6 support

@timbotimbo timbotimbo changed the title Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl. [Android gradle 8.x] Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl. Dec 2, 2024
@timbotimbo timbotimbo added the android This issue is specific to the Android Platform. label Dec 2, 2024
@muhsinPlanetMedia
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android This issue is specific to the Android Platform.
Projects
None yet
Development

No branches or pull requests

3 participants