React Native:意外令牌的转换错误(

时间:2017-08-16 22:07:16

标签: reactjs react-native native babel

我已按照React Native's Android Setup Page中显示的确切说明操作并运行代码,而不会遇到任何问题。今天,我正在尝试运行完全相同的代码。它说,正如我在下面提供的那样#34;构建是成功的#34;但我发现只有android/build/intermediates/dex-cache/cache.xml文件,而android/builid文件夹中只有ugur@ugur-Lenovo-ideapad-510-15IKB:~/Desktop/tutorials/react native tutorial/NewPro$ react-native run-android Scanning 559 folders for symlinks in /home/ugur/Desktop/tutorials/react native tutorial/NewPro/node_modules (2ms) 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:prepareComAndroidSupportSupportV42301Library UP-TO-DATE :app:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library UP-TO-DATE :app:prepareComFacebookFrescoDrawee101Library UP-TO-DATE :app:prepareComFacebookFrescoFbcore101Library UP-TO-DATE :app:prepareComFacebookFrescoFresco101Library UP-TO-DATE :app:prepareComFacebookFrescoImagepipeline101Library UP-TO-DATE :app:prepareComFacebookFrescoImagepipelineBase101Library UP-TO-DATE :app:prepareComFacebookFrescoImagepipelineOkhttp3101Library UP-TO-DATE :app:prepareComFacebookReactReactNative0471Library UP-TO-DATE :app:prepareComFacebookSoloaderSoloader010Library 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 UP-TO-DATE :app:compileDebugNdk UP-TO-DATE :app:compileDebugSources UP-TO-DATE :app:transformClassesWithDexForDebug UP-TO-DATE :app:mergeDebugJniLibFolders UP-TO-DATE :app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE :app:processDebugJavaRes UP-TO-DATE :app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE :app:validateSigningDebug :app:packageDebug UP-TO-DATE :app:assembleDebug UP-TO-DATE :app:installDebug Installing APK 'app-debug.apk' on 'SM-N910C - 6.0.1' for app:debug Installed on 1 device. BUILD SUCCESSFUL Total time: 17.032 secs Running /home/ugur/Android/Sdk/platform-tools/adb -s 4100fef8e47db1b3 reverse tcp:8081 tcp:8081 adb server version (32) doesn't match this client (39); killing... * daemon started successfully * Starting the app on 4100fef8e47db1b3 (/home/ugur/Android/Sdk/platform-tools/adb -s 4100fef8e47db1b3 shell am start -n com.newpro/com.newpro.MainActivity)... Starting: Intent { cmp=com.newpro/.MainActivity } 文件。还有以下错误as shown in this image。我想弄清楚出了什么问题。这是终端输出:

class Expense < ActiveRecord::Base
  belongs_to :category
end

class Category < ActiveRecord::Base
  has_many :expenses
end

class ExpensesController < ApplicationController
  def index
    if params[:concept] || params[:category_id]
        search = "%" + params[:concept] + "%"
        @expenses = Expense.where("concept LIKE ? OR category_id = ?", search, params[:category_id])


    else
     @expenses = Expense.order("date DESC")
    end
  end
end

我的操作系统是Elementary OS,Node v6.11.2,react-native-cli v2.0.1。

如果你指导我找出我的构建出了什么问题,我会很高兴的。

4 个答案:

答案 0 :(得分:17)

这与babel-preset-react-native模块有关。试着跑,

yarn remove babel-preset-react-native
yarn add babel-preset-react-native@2.1.0

或者如果你使用NPM,

npm uninstall babel-preset-react-native
npm install babel-preset-react-native@2.1.0

答案 1 :(得分:2)

在主题中回答了这个问题:https://stackoverflow.com/a/45778766/4621698

这对我有用。

解决方法:

$("button:first").on("click", function() {
    var targ = $("#target"),
          targHt = targ.height(),
          newTargHt = targHt + 50;

    targ.height(newTargHt);
});

$("button:last").on("click", function() {
    var targ = $("#target"),
          targHt = targ.height(),
          newTargHt = targHt - 50;

    targ.height(newTargHt);
});

见上文,现在babel-preset-react-native指向2.1.0。 然后,

"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.47.1",
"babel-preset-react-native": "2.1.0"
},

然后重新启动android或ios。

答案 2 :(得分:0)

删除node_modules文件夹,然后运行命令。

 npm install

然后运行项目。

答案 3 :(得分:0)

尝试终止端口8081上的任何进程

如果你在MAC上,那么运行命令

sudo lsof -n -i4TCP:8081