BALA CHANDAR
BALA CHANDAR

Reputation: 71

How to export React-Native App as a Android Library (.aar)?

I am new to React-Native, I have an objective of creating React-Native based components that can be used in other Android native Apps . However, we would to export this react native component as an Android library (.aar) and then distribute to other consumers.

  1. How can I export react-native module as a library.?
  2. Is there something similar to export the components to be used in IOS app development?

I have seen this question has been asked couple of times in SOF, however do not see a clear answer, hence Im posting again.

Upvotes: 7

Views: 2672

Answers (1)

Thanh Cao
Thanh Cao

Reputation: 161

In the following project, their goal was to add react-native dependencies to a vanilla Android app:

https://github.com/glung/react-native-as-an-android-lib

They note some drawbacks that the user of the Android library will face:

  • React-native requires the application to implement the ReactApplication interface to run. This means that the app needs to add a dependency to 'com.facebook.react:react-native`.

  • Final APK size will be bigger. There is not much we can do about that since about 6M comes from react-native ndk libraries (compiled for arm64-v8a, armeabi, armeabi-v7a x86 , x86_64).

    • 1.5M normal.apk
    • 8.5M react_native.apk
    • 7.9M react_native.apk proguarded

Upvotes: 5

Related Questions