-
Notifications
You must be signed in to change notification settings - Fork 12
Advanced: AAR compilation for Android
James Allen edited this page Feb 26, 2025
·
2 revisions
Unity 2022.3 is becoming quite old, and so it may increasingly become more difficult to manage dependency conflicts between Unity, Flutter, AGP, Gradle, JDK, NDK etc.
An alternative solution may be to compile the Unity project into an AAR before importing into Flutter (thanks @timbotimbo).
This has not been tested and requires some advanced knowledge so is currently out of scope for raising issues, but the roughly the process would be something like:
- Export Android from Unity as a project.
- Modify the Unity build.gradle to make it a plugin.
- apply plugin: ‘com.android.library'
- Modify the Unity androidmanifest to remove some intent/activity stuff.
- Build the modified project into an AAR using Android Studio.
- Import the AAR in Flutter gradle files.
Pros:
- Simplifies the Flutter build. No Unity build errors during a Flutter build.
- should avoid most Unity <-> Flutter version conflicts.
- AAR is more portable between computers than a Unity project with build commands.
Cons:
- Adds an extra Android build step
- Maybe Unity profiling/debugging issues?