Search Unity

Using an AAR library in a Unity project

Discussion in 'Getting Started' started by rahulshri, Feb 10, 2019.

  1. rahulshri

    rahulshri

    Joined:
    Oct 15, 2018
    Posts:
    4
    I have a library that is exported in AAR format. It contains an Application class, several Activity and Receiver classes, other Andrdoid components (a Room database, a FileProvider), various XML resources (values/bool.xml, values/string.xml, layout/custom_layout.xml etc.), images (drawable/stuff.png), AndroidManifest.xml that contains meta-data tags, certain permissions and so on. In short, a lot of stuff that is required for my game to integrate with the underlying platform.

    I still don't understand how to have Unity use this AAR. This is what I have so far:

    * I am using Gradle to build my app.
    * I have enabled custom build.gradle option.
    * The AAR file is currently in Assets/Plugins/Android/libs.

    The build often succeeds. If I open the resulting APK file in Android Studio's APK analyzer, I can:

    * See the classes from the AAR in classes.dex
    * But nothing else. Not the resources, not the stuff from the manifest.

    It appears that Unity's Gradle & AAR support have evolved over time, so the various web references don't match either. I am using Unity 2018.3.5f1.

    How do I get an AAR file to be treated nicely, and all its classes, resources & Manifest made available to the final Unity app?
     
    anycolourulike likes this.