react-native-unity icon indicating copy to clipboard operation
react-native-unity copied to clipboard

Make standalone android build with AR features. Getting error: Direct local .aar file dependencies are not supported when building an AAR.

Open dhruvaura opened this issue 11 months ago • 1 comments

I am integrating unity app with react android. Integration is successful by testing using development metro server. It's working fine as expected.

Now I am trying to make standalone debug build for testing but getting following errors. Anyone has idea how to fix and make successful standalone debug build?

Trying to make standalone debug build using this command: ./gradlew assembleDebug

> Error while evaluating property 'hasLocalAarDeps' of task ':unityLibrary:bundleDebugAar'.
   > Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :unityLibrary project caused this error: D:\Dhruv\react\unity6\react-native-unity-app-main-arr-six-cogno\unity\builds\android\unityLibrary\libs\IngameDebugConsole.aar, D:\Dhruv\react\unity6\react-native-unity-app-main-arr-six-cogno\unity\builds\android\unityLibrary\libs\arcore_client.aar, D:\Dhruv\react\unity6\react-native-unity-app-main-arr-six-cogno\unity\builds\android\unityLibrary\libs\UnityARCore.aar, D:\Dhruv\react\unity6\react-native-unity-app-main-arr-six-cogno\unity\builds\android\unityLibrary\libs\ARPresto.aar, D:\Dhruv\react\unity6\react-native-unity-app-main-arr-six-cogno\unity\builds\android\unityLibrary\libs\unityandroidpermissions.aar

@azesmway Let me know if you have any idea on above. Thanks

dhruvaura avatar Dec 19 '24 14:12 dhruvaura

I had a similar issue trying to include 3 aar libraries. You can solve it like this.

You have file IngameDebugConsole.aar inside ./unity/builds/android/unityLibrary/libs/.

  1. Within the android directory, create a directory named IngameDebugConsole
  2. Move the IngameDebugConsole.aar from ./unity/builds/android/unityLibrary/libs/ to ./android/IngameDebugConsole
  3. Create a file, build.gradle inside the ./android/IngameDebugConsole and type the following
configurations.maybeCreate("default")
artifacts.add("default", file('IngameDebugConsole.aar'))
  1. Modify the ./android/settings.gradle
+include ': IngameDebugConsole'
+project(": IngameDebugConsole").projectDir = file("./IngameDebugConsole")

include ':unityLibrary'
project(':unityLibrary').projectDir=new File('..\\unity\\builds\\android\\unityLibrary')
  1. Update ./unity/builds/android/unityLibrary/build.gradle
+implementation project(':IngameDebugConsole')
-implementation(name: 'IngameDebugConsole', ext:'aar')

You can do the same for as many libraries you want. This should resolve the error.

konsnos avatar Jan 06 '25 16:01 konsnos