react-native-builder-bob icon indicating copy to clipboard operation
react-native-builder-bob copied to clipboard

Direct local .aar file dependencies are not supported when building an AAR.

Open wilsolutions opened this issue 3 years ago • 4 comments

Hi, please, I've create a react native module that includes 2 external libraries (.aar).

It builds fine, but when I ran npx react-native run-android example --deviceId=the_device it returns the following error:

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

I'm including the .aar in the build.gradle: implementation files('lovely/cutelib.aar')

And then in the settings.gradle i do: include ':cutelib'

Note: it will run fine into Android device if I don't pass the --deviceId flag :P

Any thoughts? ty

wilsolutions avatar Jan 20 '22 23:01 wilsolutions

@wilsolutions did you find any solution?

florindumitru avatar Feb 12 '22 14:02 florindumitru

Hello @wilsolutions, @florindumitru

Are you using "aar" in package.json > react-native-builder-bob > targets ?

I'm actually able to embed 3 aar by removing this target option.

My aar(s) are inside a libs folder into the android folder

Then in my android/build.gradle I have:

dependencies {
  implementation fileTree(dir: "libs", include: ["*.aar"])
}

Also my Android Gradle Plugin Version is in 4.2.1: (I don't know if it makes any difference)

  dependencies {
    classpath 'com.android.tools.build:gradle:4.2.1'
  }

thibaultcapelli avatar Mar 08 '22 18:03 thibaultcapelli

Hello, the issue is still present even when setting the gradle version to 4.2.1.

It will work for debug builds however release builds of apps using RN > 0.64 that use our modules will fail with:

[RUN_GRADLEW] Execution failed for task ':rnModule:bundleReleaseLocalLintAar'.
[RUN_GRADLEW] > Error while evaluating property 'hasLocalAarDeps' of task ':rnModule:bundleReleaseLocalLintAar'

with the same description @wilsolutions posted.

Does anyone have a solution that will work for the new React Native versions?

abraini-Nascent avatar May 20 '22 18:05 abraini-Nascent

did you guys find a workaround ?

a-eid avatar Aug 28 '22 10:08 a-eid

Hello, the issue is still present even when setting the gradle version to 4.2.1.

It will work for debug builds however release builds of apps using RN > 0.64 that use our modules will fail with:

[RUN_GRADLEW] Execution failed for task ':rnModule:bundleReleaseLocalLintAar'.
[RUN_GRADLEW] > Error while evaluating property 'hasLocalAarDeps' of task ':rnModule:bundleReleaseLocalLintAar'

with the same description @wilsolutions posted.

Does anyone have a solution that will work for the new React Native versions?

Any solution?

cristiano-linvix avatar Oct 25 '22 00:10 cristiano-linvix

this stackoverflow answer solved the problem for me: https://stackoverflow.com/a/73699520/10933691

DaisukiTamago avatar Nov 16 '22 13:11 DaisukiTamago

Found the solution. Instead of ./gradlew assembleRelease try ./gradlew app:assembleRelease. Now APK build is working fine even with ./gradlew assembleRelease.

Dhruv2110 avatar Dec 29 '22 12:12 Dhruv2110