无法在 React Native 项目上安装 SQLite [英] Impossible to install SQLite on React Native project

查看:81
本文介绍了无法在 React Native 项目上安装 SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始一个新的 React Native 项目,包括 SQLite Storagee.

I'd like to start a new React Native project including SQLite Storagee.

我以前已经这样做了,所以我知道它应该可以工作,但今天不行......

I've already done this before so I know that it should work, but not today...

所以我已经初始化了一个新项目,在这个项目中我安装了 react-native-sqlite-storage 按照这个循序渐进的教程(https://www.npmjs.com/package/react-native-sqlite-storage),android 部分.

So I've init a new project in which I installed react-native-sqlite-storage following this step by step tutorial (https://www.npmjs.com/package/react-native-sqlite-storage), the android part.

一切都很好,直到我使用 react-native run-android 运行我的项目.

Everything is fine untill I run my project whith react-native run-android.

这是我的 package.json 文件

Here is my package.json file

{
  "name": "pokedex",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-sqlite-storage": "^4.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.5.5",
    "@babel/runtime": "^7.5.5",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.2.2",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

这是我终端中的结果.我不明白发生了什么.

Here is the result in my terminal. I don't understand what's going on.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve project :react-native-sqlite-storage.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-sqlite-storage:
          - None of the consumable configurations have attributes.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve project :react-native-sqlite-storage.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-sqlite-storage:
          - None of the consumable configurations have attributes.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s

    at checkExecSyncError (child_process.js:629:11)
    at execFileSync (child_process.js:647:13)
    at runOnAllDevices (/home/axel/leclercq.axel@gmail.com/Pokedex/Developpement - AXEL ONLY/V5/pokedex/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
    at buildAndRun (/home/axel/leclercq.axel@gmail.com/Pokedex/Developpement - AXEL ONLY/V5/pokedex/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
    at then.result (/home/axel/leclercq.axel@gmail.com/Pokedex/Developpement - AXEL ONLY/V5/pokedex/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

我尝试过各种版本的 react-native 和 sqlite-storage,但没有任何效果.

I've tried it with various version of both react-native and sqlite-storage but nothing works.

需要帮助请

推荐答案

嘿,我找到了解决方案!只需转到您的 settings.gradle 文件并更改这条线project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')

Hey I found the solution! Just go to your settings.gradle file and change THIS LINE project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')

为此project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/platforms/android')

TO THIS project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/platforms/android')

您好!

这篇关于无法在 React Native 项目上安装 SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆