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

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

Open dougbradbury opened this issue 3 years ago • 7 comments

I upgraded to react-native 0.64.2 (which included upgrading to gradle 6.7 and the android gradle plugin) and encountered this error

What went wrong: Execution failed for task ':react-native-serialport:bundleReleaseAar'.

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 :react-native-serialport project caused this error: .../node_modules/react-native-serialport/android/libs/usbserial-6.0.5-release.aar

I've been trying to make the change according to this article but I am out of my depth on gradle.

dougbradbury avatar Jan 10 '22 12:01 dougbradbury

https://github.com/mikafi/react-native-serialport has solved the problem.

dougbradbury avatar Jan 10 '22 12:01 dougbradbury

I just ran into same issue as you can see here, when I run ./gradlew assembleRelease, after adding react-native-serialport to my project:

Screenshot 2022-11-28 at 16 38 03

How did you resolve it, @dougbradbury ?

"react-native-serialport": "^1.3.1" "react-native": "0.65.1"

com.android.tools.build:gradle:4.2.1

jankoJelic avatar Nov 28 '22 15:11 jankoJelic

resolved this with app:assembleRelease instead of assembleRelease

jankoJelic avatar Nov 29 '22 18:11 jankoJelic

resolved this with app:assembleRelease instead of assembleRelease

@jankoJelic , I am using app:assembleRelease for building the app but am still facing the same issue. do you mind sharing how exactly you solved this issue? I've tried to find a solution online and most of them are suggesting adding some settings on build.gradle file and none of them is working.

error details: 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 :react-native-serialport project caused this error: C:....\wimiti\node_modules\react-native-serialport\android\libs\usbserial-6.0.5-release.aar

TetaBelyse avatar May 22 '23 07:05 TetaBelyse

Did you guys manage to get a solution for this issue? still facing this issue. I am using "react-native-serialport": "^1.3.1"

fabrice-niyongabo avatar May 22 '23 07:05 fabrice-niyongabo

After a couple of days of trying to find a solution online, none of them worked. I have come up with a solution for this issue, just follow 4 simple steps:

  1. Copy libs folder from yourProject/node_modules/react-native-serialport/android and then paste it into yourProject/android/app

  2. From yourProject/node_modules/react-native-serialport/android/build.gradle

Under dependencies, change this line: implementation fileTree(dir: 'libs', include: ['usbserial-6.0.5-release.aar']) to compileOnly fileTree(dir: 'libs', include: ['usbserial-6.0.5-release.aar'])

  1. Make sure that you have made the necessary configurations for building a signed APK. More details on the official site

  2. Now build your project by: cd android then run ./gradlew clean assembleRelease

Now, you should be able to build your project.

fabrice-niyongabo avatar Jul 25 '23 11:07 fabrice-niyongabo