android - React-Native - react-native-update-gradle - 错误

标签 android react-native gradle

我的 Android React-Native 项目出现错误。

我的第一个错误如下:

我添加了“react-native-location”库。在我运行命令“react-native link”后,抛出错误“compileOnly”。 所以我的第一个尝试是更新 NPM 和 Node.JS。 但这不是我的问题的正确解决方案。

在那之后,我用谷歌搜索了错误,我想用“react-native-update-gradle”更新 grandle。我现在的主要问题是,当我运行“react-native link”命令时,出现以下错误:

    C:\Computer\Apps\Projects\XXX>react-native link
Scanning folders for symlinks in C:\Computer\Apps\Projects\XXX\node_modules (70ms)
rnpm-install info Platform 'ios' module react-native-orientation is already linked
rnpm-install info Platform 'android' module react-native-orientation is already linked
internal/validators.js:125
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at validateString (internal/validators.js:125:11)
    at Object.join (path.js:427:7)
    at getSDKPath (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\index.js:13:12)
    at getPTPath (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\index.js:17:20)
    at Object.activateADB (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\index.js:5:42)
    at Object.<anonymous> (C:\Computer\Apps\Projects\XXX\node_modules\react-native-update-gradle\cli.js:101:6)
    at Module._compile (internal/modules/cjs/loader.js:734:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
C:\Computer\Apps\Projects\XXX\node_modules\react-native\local-cli\core\makeCommand.js:27
        throw new Error(`Error occurred during executing "${command}" command`);
        ^

Error: Error occurred during executing "node ./node_modules/react-native-update-gradle/cli.js" command
    at ChildProcess.prelink (C:/Computer/Apps/Projects/XXX/node_modules/react-native/local-cli/core/makeCommand.js:27:15)
    at ChildProcess.emit (events.js:197:13)
    at maybeClose (internal/child_process.js:978:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)

我尝试修复错误,但错误仍然存​​在。

我有以下环境

  • 窗口 10
  • React-Native 0.55.4
  • React-Native-Cli 2.0.1
  • NodeJS v11.9.0
  • npm 4.6.0

android/build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com'
        }
    }
}

ext {
    compileSdkVersion   = 28
    targetSdkVersion    = 28
    buildToolsVersion   = "28.0.3"
    supportLibVersion   = "28.1.1"
    playServicesVersion = "15.0.1"
}

package.json

 {
  "name": "XXX",
  "version": "1.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "run-android": "react-native run-android"
  },
  "dependencies": {
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-image-slider": "^2.0.3",
    "react-native-image-zoom-viewer": "^2.2.25",
    "react-native-orientation": "^3.1.3",
    "react-native-pinch-zoom-view": "^0.1.6",
    "react-native-responsive-image": "^2.3.1",
    "react-native-router-flux": "^4.0.0-beta.28",
    "react-native-scrolltotop": "0.0.6",
    "react-native-slideshow": "^1.0.1",
    "react-native-swipe-gestures": "^1.0.2",
    "react-native-update-gradle": "^1.1.0",
    "react-native-vector-icons": "^4.6.0",
    "react-native-zoom-view": "^1.0.2"
  },
  "devDependencies": {
    "babel-jest": "22.4.3",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.4.3",
    "react-test-renderer": "16.3.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

如果您需要更多信息来帮助我,请告诉我。

感谢您的帮助。

最好的问候

最佳答案

Sebastian !运行命令 react-native link 后,您必须运行命令 react-native run-androidreact-native run-ios .这样您安装的库就会适应您的 React Native 设置。在我安装库或包之后,这对我有用。希望这会有所帮助。

关于android - React-Native - react-native-update-gradle - 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54481080/

相关文章:

android - 我需要将 Android textInput 限制为仅 ISO-8859-1 字符

reactjs - 直到按下 2 'backspace' 才意识到 TextInput 是空的

android - 卡在 Gradle 构建运行中

java - 如何刷新 gradle 任务的目标

gradle - 将发布配置移动到 gradle 中的一个位置

Android - 如果设备在注册接收器的情况下重新启动,我的后台服务注册的广播接收器无法关闭

android - 应用程序在 setContentView android 上崩溃,没有堆栈跟踪

java - 如何使用fromJson方法解析json

javascript - 如何在 native react 中访问从 firebase 数据库检索到的完整数组?

javascript - 如何更新我的 isFetching 属性以使 Activity Spinner 正常工作?