react-native-sqlite-storage: [react-native]After adding Sqlite to the project, Error occurs
My React Native Project configuration is
{ "name": "AwesomeProject", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "react": "16.5.0", "react-native": "0.57.0", "react-native-sqlite-storage": "^3.3.6" }, "devDependencies": { "babel-jest": "23.6.0", "jest": "23.6.0", "metro-react-native-babel-preset": "^0.45.0", "react-test-renderer": "16.5.0" }, "jest": { "preset": "react-native" } }
I am Writing Down What Instructions I followed, please Try to spot where I am wrong
In setting.gradle
rootProject.name = 'AwesomeProject'
include ':react-native-sqlite-storage' project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
include ':app
’
`
In Android/app/build.gradle
dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" implementation "com.facebook.react:react-native:+" // From node_modules compile project(':react-native-sqlite-storage') }
In MainApllication.java
…import org.pgsqlite.SQLitePluginPackage;
…
…@Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new SQLitePluginPackage(), new MainReactPackage() ); }
…
Thankyou for helping Me P.s :- Sorry of My Bad English
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 15 (2 by maintainers)
Commits related to this issue
- Resolve #294: add google() repo, use gradle 3.1.4 (#309) — committed to andpor/react-native-sqlite-storage by spruce-bruce 6 years ago
Hi, I had a lot of dependencies errors after trying to install react-native-sqlite-storage and i solved it by changing the path in the settings.gradle : I replace project(‘:react-native-sqlite-storage’).projectDir = new File(rootProject.projectDir, ‘…/node_modules/react-native-sqlite-storage/src/android’) by project(‘:react-native-sqlite-storage’).projectDir = new File(rootProject.projectDir, ‘…/node_modules/react-native-sqlite-storage/platforms/android’)
Another thing was that I didn’t put anything in the mainApplication file, I din’t add any package, which gives me this : @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 MyReactNativePackage()); return packages; }
I hope it helps
@tonycapone The PR I submitted fixed the issue for me. For now I’ve got
"react-native-sqlite-storage": "git://github.com:spruce-bruce/react-native-sqlite-storage.git#resolve-gradle-dep",
in my package.json and that allows my builds to succeed. Once my PR is merged I’ll be able to switch back to the npm module@filippoitaliano If you are using prepopulated database then you may want to test this https://github.com/sameerjain/SQLiteDemo and see if that compile well and run as expected on android.