AAR imports

Hello, I am trying to import .class files that are packaged in an AAR. I have searched around and thought I had figured out how to do it, but when I attempt to refer to one of the classes the JNI throws a class not found error.

The approach I took was to use the <buildGradleAdditions> node in the UPL to add my AAR as a dependencies.implementation, e.g.:



  <buildGradleAdditions>
    <log text="Processing Gradle additions ..."/>
    <insert>
      allprojects {
          repositories {
              google()
              jcenter()
              flatDir {
    </insert>
    <insertValue value="dirs '$S(BuildDir)/libs'"/>
    <insertNewline/>
    <insert>
          }
        }
      }

      dependencies.implementation(name: 'my_super_sweet_aar', ext: 'aar')

      }
    </insert>
  </buildGradleAdditions>


(This is after a copy step that copies the AAR to the specified location).

This executes, but again when I try to refer to a class in the AAR everything crashes.

Is it still necessary to do the AARImport step, even if you are list the AAR as a dependency in Gradle?

Following up with a note that if I examine the resulting APK in Android Studio, I can see the class I’m trying to use in the classes.dex. So it’s definitely packing the AAR. It’s just for some reason when code attempts to refer to a class in the AAR it is unable to find it.

Did you have some solution?