我有一个工作正常的Android react native应用程序(react native v 0.60.5)。我试图在应用程序中使用Sqlite存储,但显示此错误
build.gradle: 实施项目(':react-native-sqlite-storage')
MainApplication.js file
import org.pgsqlite.SQLitePluginPackage;
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new SQLitePluginPackage());
return packages;
}
Setting.gradle
include ':react-native-sqlite-storage'
project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
package.json
{
"name": "AfblSellsApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"axios": "^0.19.0",
"react": "16.8.6",
"react-native": "0.60.5",
"react-native-elements": "^1.2.0",
"react-native-linear-gradient": "^2.5.6",
"react-native-magic-move": "^0.6.6",
"react-native-modal": "^11.4.0",
"react-native-numeric-input": "^1.8.3",
"react-native-router-flux": "^4.0.6",
"react-native-shadow": "^1.2.2",
"react-native-sqlite-storage": "^4.1.0",
"react-native-svg": "^9.9.4",
"react-native-svg-uri": "^1.2.3",
"react-native-vector-icons": "^6.6.0",
"react-redux": "^7.1.1",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/runtime": "^7.6.0",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.4.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"./assets/fonts/"
]
}
}
我该如何解决我的问题
答案 0 :(得分:1)
我的android / settings.gradle是
rootProject.name = 'Awesomeproject'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':react-native-sqlite-storage'
project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/platforms/android')
include ':app'
并且android \ app \ src \ main \ java \ com \ awesomeproject \ MainApplication.java中没有任何更改
它有效!