$ npm install react-native-bpg --save
$ react-native link react-native-bpg
NDK should be installed. This can be done with SDK manager.
Project should contain ./android/local.properties
with correct paths to SDK/NDK (it is possible to set up environment variables).
Windows example:
sdk.dir=D\:\\Development\\_SDK\\AndroidSDK\\AndroidSDK
ndk.dir=D\:\\Development\\_SDK\\AndroidSDK\\ndk-bundle
There will be the warnings during the native libraries build phase.
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.kornell.bpg.RNReactNativeBpgPackage;
to the imports at the top of the file - Add
new RNReactNativeBpgPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-bpg' project(':react-native-bpg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-bpg/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-bpg')
Not implemented for iOS
Not implemented for Windows
Example project can be found in links section
Thank to the author of this article
filter getList with .bpg$ pattern
add png support
add gif support
add download from web (check with self-signed ssl and provide option to enable skip-checking)
add methods for
*AsPromise
rename current methods to
*AsCallback
If native libs are not building, try several techniques to clean cache:
npm start -- --reset-cache
remove node_modules and install dependencies again with npm i
On Windows
remove %USER_HOME%.gradle\caches\
On Mac or Linux: > rm -rf $HOME/.gradle/caches/
On Both
> cd android
> gradlew cleanBuildCache
then rebuild an application.