Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dougbradbury opened this issue Jan 10, 2022 · 7 comments

Comments

@dougbradbury
Copy link

dougbradbury commented Jan 10, 2022

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
Copy link
Author

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

@jankoJelic
Copy link

jankoJelic commented Nov 28, 2022

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
Copy link

resolved this with app:assembleRelease instead of assembleRelease

@TetaBelyse
Copy link

TetaBelyse commented May 22, 2023

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

@fabrice-niyongabo
Copy link

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
Copy link

fabrice-niyongabo commented Jul 25, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants