Sifir-io / react-native-tor

Tor Daemon and Socks5 client for React Native iOS and Android projects!
MIT License
101 stars 16 forks source link

./gradlew assembleRelease throws "Direct local .aar file dependencies are not supported when building an AAR" #3

Closed Overtorment closed 3 years ago

Overtorment commented 3 years ago

When trying to build release:

> Task :react-native-tor:bundleReleaseAar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-tor: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-tor project caused this error: /home/overtorment/Documents/BlueWallet/node_modules/react-native-tor/android/libs/sifir_android.aar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 31s
1117 actionable tasks: 272 executed, 845 up-to-date

Related PR: BlueWallet/BlueWallet/pull/2295

gabidi commented 3 years ago

Thanks for this, Good catch.

gabidi commented 3 years ago

Will publish AAR to a public maven repo, and update the module deps to use the repo instead. That should fix this.

Overtorment commented 3 years ago

thanks!

gabidi commented 3 years ago

@Overtorment I just tried building Sifir (which I use react-native-tor as a dependency in ).

  1. Build as an AAB:
    [gus@homebase android]$ ./gradlew bundleRelease
    Configuration on demand is an incubating feature.
    ....
    info Writing bundle output to:, /home/gus/Projects/sifir-app/android/app/build/generated/assets/react/release/index.android.bundle      
    info Writing sourcemap output to:, /home/gus/Projects/sifir-app/android/app/build/generated/sourcemaps/react/release/index.android.bundle.map
    info Done writing bundle output
    info Done writing sourcemap output
    info Copying 136 asset files
    info Done copying assets
    ....
    BUILD SUCCESSFUL in 1m 21s
    454 actionable tasks: 8 executed, 446 up-to-date
    1. as an APK:
      $ cd android && ./gradlew assembleRelease
      ....
      BUILD SUCCESSFUL in 3m 9s
      695 actionable tasks: 695 executed
  2. as a test release APK:
    ./node_modules/react-native/cli.js run-android --variant=release
    BUILD SUCCESSFUL in 1m 25s
    450 actionable tasks: 423 executed, 27 up-to-date
    info Connecting to the development server...
    info Starting the app on "emulator-5554"...
    Starting: Intent { cmp=com.sifir/.MainActivity }

    and I tried the build having both github and npm as the source of react-native-tor.

What's the command you guys use to build your APKs/AAB ? Or are you trying to build react-native-tor into another AAR ? Let me know thanks!

Overtorment commented 3 years ago

Im not very good with andoid build scripts (IMO its a nightmare). the steps to reproduce are:

git clone git@github.com:BlueWallet/BlueWallet.git
cd BlueWallet/
git checkout --track origin/tor4lndhub
npm i
cd android/
./gradlew assembleRelease

result:

> Task :react-native-tor:bundleReleaseAar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-tor: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-tor project caused this error: /tmp/BlueWallet/node_modules/react-native-tor/android/libs/sifir_android.aar

afaik this is roughly the same appcenter.ms does (its our CI/build server) to make us a production apk

Overtorment commented 3 years ago

any progress?

gabidi commented 3 years ago

Nope, haven't really looked into this as it seems more of a build/CI issue when trying to build Bluewallet as an AAR. Maybe someone or another project can explain why that is being done for an Application ? I'll keep this issue open so others can comment on it should they be facing the same issue.

Overtorment commented 3 years ago

I did some googling, and looks like its gradle4 to blame (gradle3 works fine), so any RN project that is built with gradle4 will experience this.

the solution might be to upload AAR to maven and link it from there. OR to manually include AAR in my build.gradle file (that's what Im gonna try to do next)

https://stackoverflow.com/questions/60878599/error-building-android-library-direct-local-aar-file-dependencies-are-not-supp/63665094#63665094 https://github.com/transistorsoft/react-native-background-geolocation/issues/1077 https://stackoverflow.com/questions/16682847/how-to-manually-include-external-aar-package-using-new-gradle-android-build-syst/23326397#23326397

gabidi commented 3 years ago

If uploading the AAR solves it for you then I think that is doable from the point of view of this repo. I also think it's probably gonna be easier for you to track and stay up to date considering this repo is new and not mature yet. I'll do it this week and let you know, so you can give it a try.

Overtorment commented 3 years ago

lets try uploading to maven, yes. then react-native-tor will have to reference it from maven. Ill try to solve it manually, meanwhile

Overtorment commented 3 years ago

in a change that I did here https://github.com/Sifir-io/react-native-tor/pull/10 maven upload is not necessary

gabidi commented 3 years ago

left a comment on your PR. I dont think compileOnly is the way to go

gabidi commented 3 years ago

Commented on #10 , let me know what you think.

gabidi commented 3 years ago

Handled by #10