Closed giacomoran closed 4 years ago
Before merging, we should probably update instructions in the README about how to use this library.
Here are the instructions:
if you are cloning this project either clone with git clone --recurse-submodules git@github.com:andymatuschak/react-native-leveldown.git
or, after cloning, run git submodule update --init --recursive
in android/settings.gradle
, add at the end of the file:
include ':react-native-leveldown'
project(':react-native-leveldown').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-leveldown/android')
apply from: '../node_modules/react-native-leveldown/android/settings.gradle'
project(':leveldb-android').projectDir = new File(rootDir, '../node_modules/react-native-leveldown/android/modules/leveldb-
android/leveldb/')
You can use testapp/android/settings.gradle as a reference.
in android/app/build.gradle
add:
dependencies {
// ...
implementation project(':react-native-leveldown')
}
in MainApplication.java
add packages.add(new LeveldownPackage());
to the getPackages()
method, like this:
import com.reactnativeleveldown.LeveldownPackage;
// ...
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
packages.add(new LeveldownPackage());
return packages;
}
// ...
add a react-native.config.js
file in the root of your project, add:
module.exports = {
dependencies: {
'react-native-leveldown': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
},
},
},
};
The testapp project serves as reference for the instructions.
The first instruction is required since I've added the leveldb-android
dependency as a git submodule. If it is a problem, I can push the dependency in some repository and include it from there.
Hooray! I just ran the Android test suite, and everything looks great.
I'll merge this, then update the Readme, add the Android paths to package.json so it's included in NPM, then publish 1.0.
Thank you so much, @RAN3000!
Done: d07acd1. We're now at 1.0! Thanks again—looking forward to getting Orbit up and running on Android…
I've added a React Native Android module, all tests pass. The module relies on my own fork of leveldb-android.
The initial idea was to use android-leveldb by litl but I've found that it lacked some functionalities required by the abstract-leveldown interface. I've found another similar project: leveldb-android by hf. It was more complete but it still lacked support for the
errorIfMissing
configuration parameter. I forked the library and added the parameter (actually there was an umerged pull request sitting around in the original project with the required feature, I copied the code over to the fork).Resolves #1