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

feat: add a target to build Android AAR files with support for reverse Jetify #4

Merged
merged 1 commit into from
Jun 18, 2019

Conversation

matt-oakes
Copy link
Contributor

Summary

This PR adds a target which assembles Android AAR files for a library. This is needed to help workaround the migration to AndroidX. See the discussion here for details:

react-native-community/discussions-and-proposals#129

The idea is that we can migrate a library to AndroidX and then generate AAR files which can then be converted back to the Android Support Library using the "reverse jetty" tool.

This target automates this process by running ./gradlew assemble and then copying the output AAR to the correct folder. This then optionally converts it to the support library using the jetifier package.

Test Plan

You need to add the aar target to a project and then run yarn bob build to test the output. Example output when run:

$ bob build
ℹ Building target aar
ℹ Cleaning up previous build at lib/aar
ℹ Assembling Android project in android with gradle
ℹ Creating new output directory at lib/aar
ℹ Copying AAR from android/build/outputs/aar/android.aar to lib/aar/android.aar
ℹ Creating AAR Gradle file at lib/aar/build.gradle
ℹ Creating new support output directory at lib/aar/support
ℹ Using Jetifier to convert AAR from AndroidX to Support AAR at lib/aar/support/android.aar
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
ℹ Creating Support AAR Gradle file at lib/aar/support/build.gradle
✓ Wrote files to lib/aar
ℹ Building target commonjs
ℹ Cleaning up previous build at lib/commonjs
ℹ Compiling 8 files in src with babel
✓ Wrote files to lib/commonjs
ℹ Building target module
ℹ Cleaning up previous build at lib/module
ℹ Compiling 8 files in src with babel
✓ Wrote files to lib/module
✨  Done in 2.68s.

The output files:

image

These can then be used by the user by changing their project imports in android/settings.gradle like this:

include ':react-native-community-netinfo'
- project(':react-native-community-netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')
+ project(':react-native-community-netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/lib/aar/support')

@mikehardy
Copy link

I don't have bob experience but I have android native experience, and some typescript, and in general this looks spot-on. I wasn't even sure if bridging the support/AndroidX chasm was going to be possible a couple days ago and now it looks like it won't even hurt much. Very cool

@satya164
Copy link
Member

satya164 commented Jun 9, 2019

Hey! Sorry for the late review. This looks great. What do you think about @thymikee's comment?

@matt-oakes
Copy link
Contributor Author

@satya164 I've added that in now 👍

@mikehardy
Copy link

Is there anything blocking this? I'd like to be able to recommend it - Clip-sub/react-native-bottomsheet#22

@satya164
Copy link
Member

Sorry, totally forgot about it. Will merge and do a release now.

@satya164 satya164 changed the title Add a target to build Android AAR files with support for reverse Jetify feat: add a target to build Android AAR files with support for reverse Jetify Jun 18, 2019
@satya164 satya164 merged commit 3264f5e into callstack:master Jun 18, 2019
@mikehardy
Copy link

Fantastic! thank you (and thanks @matt-oakes) 💪

@matt-oakes matt-oakes deleted the android-aar branch June 19, 2019 05:02
@slorber
Copy link

slorber commented Jul 15, 2019

Hey,

I'm not an android dev and not sure exactly what this feature does.
Just wanted to use bob in a non-native expo compatible lib and copied the default readme conf but it failed due to missing gradlew in my path.

I think it would be cool to give more explainations on readme. I suppose using this features does not make sense for non-native libs right? (related to this pr: react-navigation/hooks#27)

satya164 pushed a commit that referenced this pull request Sep 15, 2023
### Summary

This removes the (non-working) support for `aar` targets.
Originally, the `aar` support was added with #4 to support AndroidX.
However, it's not needed anymore so we are removing the support.

### Test plan

1. Create a new library with `npx create-react-native-library`
2. Add `aar` to targets
3. run `yarn prepack`
4. Make sure an error is printed and the program stops.
@BinniZenobioCordovaLeandro
Copy link

BinniZenobioCordovaLeandro commented Jul 23, 2024

I have a similar problem trying to add a module in android directory:

I already configure:
settings.gradle

include ':library'
project(':library').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fire-tv/android/libs/library')

and I added implementation project to build.gradle

implementation project(':library')

but it always shows the error:

* Where:
Build file '/Users/binni.cordova/globant/NFL/MyTVApp/node_modules/react-native-fire-tv/android/build.gradle' line: 97

* What went wrong:
A problem occurred evaluating project ':react-native-fire-tv'.
> Project with path ':library' could not be found in project ':react-native-fire-tv'.

Screenshot 2024-07-23 at 11 59 10 AM

Screenshot 2024-07-23 at 11 59 26 AM

@matt-oakes @slorber

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

Successfully merging this pull request may close these issues.

7 participants