React-Native运行android错误Java不是增量的,react-native升级版本与node_module不匹配

时间:2018-10-16 08:52:44

标签: android react-native node-modules

我刚刚使用初始化命令create-react-native-app开始了我的项目,并安装了所有前提条件。

命令react-native run-android出现问题

Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComFacebookFrescoDrawee081Library UP-TO-DATE
:app:prepareComFacebookFrescoFbcore081Library UP-TO-DATE
:app:prepareComFacebookFrescoFresco081Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipeline081Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineOkhttp081Library UP-TO-DATE
:app:prepareComFacebookReactReactNative0201Library UP-TO-DATE
:app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).

我试图进行搜索,并且人们正在谈论升级react-native,但是当我尝试“ react-native-git-upgrade”时,我的“ package.json”版本出现了错误。

    git-upgrade info Check for updates 
git-upgrade info Read package.json files 
git-upgrade info Check declared version 
git-upgrade info Check matching versions 
git-upgrade ERR! An error occurred during upgrade: 
git-upgrade ERR! Error: react-native version in "package.json" (https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz) doesn't match the installed version in "node_modules" (0.55.4).
Try running "npm install" to fix this.
    at checkMatchingVersions (/usr/local/lib/node_modules/react-native-git-upgrade/checks.js:24:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:253:5)
    at Generator.next (<anonymous>)
    at step (/usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:171:191)
    at /usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:171:361
    at tryCallOne (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/promise/lib/core.js:37:12)
    at /usr/local/lib/node_modules/react-native-git-upgrade/node_modules/promise/lib/core.js:123:15
    at flush (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/asap/raw.js:50:29)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9) 

当我npm install进行任何更改时,我尝试删除自己的node_modules目录,并使用npm install创建一个新目录,但是它没有变化。

我在Ubuntu上,几天以来一直在为此苦苦挣扎...

1 个答案:

答案 0 :(得分:0)

我认为这些步骤将为您提供帮助。

  1. 转到您的项目目录并运行此命令[Ubuntu:cd android && ./gradlew clean]
  2. 假设您位于ubuntu的android目录[rm -rf build中,请从android目录中删除构建文件夹
  3. 如果此步骤未产生任何结果,请执行步骤[1,2] 然后删除 node_modules 目录并在之后运行npm install 在项目的根目录中跟随[1,2]。
  4. 最后,从项目根目录使用此命令react-native run-android