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

Add Android Gradle Plugin (AGP) 8.0 compatibility. #807

Closed
wants to merge 3 commits into from

Conversation

timbotimbo
Copy link
Collaborator

Description

Android Gradle Plugin 8.0 requires a namespace definition in some build.gradle files.
This is incompatible with the current plugin 2022.2.0.

After updating to AGP 8.0, you will get errors like this:

* Where:
Build file '...\flutter_unity_widget\example\android\build.gradle' line: 31

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not create an instance of type com.android.build.api.variant.impl.ApplicationVariantImpl.
      > Namespace not specified. Please specify a namespace in the module's build.gradle file like so:

        android {
            namespace 'com.example.namespace'
        }

        If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

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

This pull request adds backwards compatible namespace definitions, following the example of the official Flutter plugins.

  • Adds the namespace to the plugin build.gradle and example/app/build.gradle
  • Makes the Unity export script add the namespace to unityLibrary/build.gradle.

Testing:

(1,2 and 3 can be done by manually editing gradle files too)

  1. Install Android Studio Flamingo (2022.2.x) or newer.
  2. Open Example/android in Android studio.
  3. Use the upgrade assistant to update Gradle to 8.0 and the Gradle plugin (AGP) to 8.0.
    (it should pop up automatically, otherwise open it from Tools -> AGP upgrade assistant)
  4. Export Android from Unity
  5. Build/Run the flutter app.

The build should work again with these changes.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@WouterVandenputte
Copy link

Like the effort that you put in to it. Any idea why this is not yet approved?

@timbotimbo
Copy link
Collaborator Author

Nobody else is really contributing anymore and I can't approve my own pull requests.
I've now started forcing some PRs through using a workaround.

@timbotimbo timbotimbo closed this Jun 25, 2024
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.

3 participants