taro icon indicating copy to clipboard operation
taro copied to clipboard

taro-native-shell 壳子,android studio 启动报错,具体报错信息看内容。

Open dxhuii opened this issue 7 years ago • 27 comments

问题描述

默认官方包,只修改了 moduleName 名字 ,xcode 可以正常启动。

复现步骤

默认官方包,只修改了 moduleName 名字

期望行为 解决此问题

报错信息

06/25 18:41:02: Launching app
$ adb push /Users/bq-dn-zj-497/Documents/plain/taro/taro-native-shell/android/app/build/outputs/apk/app-debug.apk /data/local/tmp/com.tarodemo
$ adb shell pm install -t -r "/data/local/tmp/com.tarodemo"
Success
APK installed in 8 s 736 ms
$ adb shell am start -n "com.tarodemo/com.tarodemo.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 5463 on device emulator-5554
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
V/fb-UnpackingSoSource: locked dso store /data/user/0/com.tarodemo/lib-main
V/fb-UnpackingSoSource: deps mismatch on deps store: regenerating
    so store dirty: regenerating
D/ApkSoSource: not allowing consideration of lib/x86/libfb.so: deferring to libdir
    not allowing consideration of lib/x86/libfolly_json.so: deferring to libdir
    not allowing consideration of lib/x86/libglog.so: deferring to libdir
    not allowing consideration of lib/x86/libglog_init.so: deferring to libdir
D/ApkSoSource: not allowing consideration of lib/x86/libgnustl_shared.so: deferring to libdir
    not allowing consideration of lib/x86/libicu_common.so: deferring to libdir
    not allowing consideration of lib/x86/libimagepipeline.so: deferring to libdir
    not allowing consideration of lib/x86/libjsc.so: deferring to libdir
D/ApkSoSource: not allowing consideration of lib/x86/libprivatedata.so: deferring to libdir
    not allowing consideration of lib/x86/libreactnativejni.so: deferring to libdir
    not allowing consideration of lib/x86/libyoga.so: deferring to libdir
V/fb-UnpackingSoSource: regenerating DSO store com.facebook.soloader.ApkSoSource
V/fb-UnpackingSoSource: starting syncer worker
V/fb-UnpackingSoSource: releasing dso store lock for /data/user/0/com.tarodemo/lib-main (from syncer thread)
    not releasing dso store lock for /data/user/0/com.tarodemo/lib-main (syncer thread started)
D/ReactNative: ReactInstanceManager.ctor()
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
D/ReactNative: ReactInstanceManager.createReactContextInBackground()
    ReactInstanceManager.recreateReactContextInBackgroundInner()
D/OpenGLRenderer: HWUI GL Pipeline
D/: HostConnection::get() New Host Connection established 0xd937d600, tid 5503
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/OpenGLRenderer: Swap behavior 0
D/EGL_emulation: eglCreateContext: 0xdd884420: maj 3 min 0 rcv 3
D/EGL_emulation: eglMakeCurrent: 0xdd884420: ver 3 0 (tinfo 0xdd8833b0)
W/unknown:ReactNative: Could not parse DebugServerException from: {"message":"Cannot find entry file index.js in any of the roots: [\"/Users/bq-dn-zj-497/Documents/plain/taro/demo\"]","name":"NotFoundError","type":"NotFoundError","status":404,"errors":[{"description":"Cannot find entry file index.js in any of the roots: [\"/Users/bq-dn-zj-497/Documents/plain/taro/demo\"]"}],"stack":"NotFoundError: Cannot find entry file index.js in any of the roots: [\"/Users/bq-dn-zj-497/Documents/plain/taro/demo\"]\n    at DependencyGraph.getAbsolutePath (/Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/node-haste/DependencyGraph.js:317:11)\n    at /Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:280:416\n    at Generator.next (<anonymous>)\n    at step (/Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:445)\n    at /Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:605\n    at process._tickCallback (internal/process/next_tick.js:68:7)"}
    org.json.JSONException: No value for filename
        at org.json.JSONObject.get(JSONObject.java:392)
        at org.json.JSONObject.getString(JSONObject.java:553)
        at com.facebook.react.common.DebugServerException.parse(DebugServerException.java:65)
        at com.facebook.react.devsupport.BundleDownloader.processBundleResult(BundleDownloader.java:257)
        at com.facebook.react.devsupport.BundleDownloader.access$200(BundleDownloader.java:35)
        at com.facebook.react.devsupport.BundleDownloader$1.onResponse(BundleDownloader.java:153)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
E/unknown:ReactNative: Unable to download JS bundle
    com.facebook.react.common.DebugServerException: The development server returned response error code: 404
    
    URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false
    
    Body:
    {"message":"Cannot find entry file index.js in any of the roots: [\"/Users/bq-dn-zj-497/Documents/plain/taro/demo\"]","name":"NotFoundError","type":"NotFoundError","status":404,"errors":[{"description":"Cannot find entry file index.js in any of the roots: [\"/Users/bq-dn-zj-497/Documents/plain/taro/demo\"]"}],"stack":"NotFoundError: Cannot find entry file index.js in any of the roots: [\"/Users/bq-dn-zj-497/Documents/plain/taro/demo\"]\n    at DependencyGraph.getAbsolutePath (/Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/node-haste/DependencyGraph.js:317:11)\n    at /Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:280:416\n    at Generator.next (<anonymous>)\n    at step (/Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:445)\n    at /Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:605\n    at process._tickCallback (internal/process/next_tick.js:68:7)"}
        at com.facebook.react.devsupport.BundleDownloader.processBundleResult(BundleDownloader.java:266)
        at com.facebook.react.devsupport.BundleDownloader.access$200(BundleDownloader.java:35)
        at com.facebook.react.devsupport.BundleDownloader$1.onResponse(BundleDownloader.java:153)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
W/unknown:InspectorPackagerConnection: Couldn't connect to packager, will silently retry
D/EGL_emulation: eglMakeCurrent: 0xdd884420: ver 3 0 (tinfo 0xdd8833b0)
D/EGL_emulation: eglMakeCurrent: 0xdd884420: ver 3 0 (tinfo 0xdd8833b0)
E/unknown:ReactNative: Exception in native call
    com.facebook.react.common.DebugServerException: The development server returned response error code: 404
    
    URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false
    
    Body:
    {"message":"Cannot find entry file index.js in any of the roots: [\"/Users/bq-dn-zj-497/Documents/plain/taro/demo\"]","name":"NotFoundError","type":"NotFoundError","status":404,"errors":[{"description":"Cannot find entry file index.js in any of the roots: [\"/Users/bq-dn-zj-497/Documents/plain/taro/demo\"]"}],"stack":"NotFoundError: Cannot find entry file index.js in any of the roots: [\"/Users/bq-dn-zj-497/Documents/plain/taro/demo\"]\n    at DependencyGraph.getAbsolutePath (/Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/node-haste/DependencyGraph.js:317:11)\n    at /Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:280:416\n    at Generator.next (<anonymous>)\n    at step (/Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:445)\n    at /Users/bq-dn-zj-497/Documents/plain/taro/demo/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:11:605\n    at process._tickCallback (internal/process/next_tick.js:68:7)"}
        at com.facebook.react.devsupport.BundleDownloader.processBundleResult(BundleDownloader.java:266)
        at com.facebook.react.devsupport.BundleDownloader.access$200(BundleDownloader.java:35)
        at com.facebook.react.devsupport.BundleDownloader$1.onResponse(BundleDownloader.java:153)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
D/EGL_emulation: eglMakeCurrent: 0xdd884420: ver 3 0 (tinfo 0xdd8833b0)
I/zygote: Do partial code cache collection, code=29KB, data=26KB
    After code cache collection, code=29KB, data=26KB
    Increasing code cache capacity to 128KB
I/zygote: Do partial code cache collection, code=58KB, data=47KB
I/zygote: After code cache collection, code=58KB, data=47KB
    Increasing code cache capacity to 256KB
I/zygote: Background concurrent copying GC freed 34127(2MB) AllocSpace objects, 3(76KB) LOS objects, 67% free, 749KB/2MB, paused 29.945ms total 208.595ms
Device emulator-5554disconnected, monitoring stopped.

系统信息

Taro v1.3.4
  Taro CLI 1.3.4 environment info:
    System:
      OS: macOS 10.14
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.15.3 - /usr/local/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
    npmPackages:
      @tarojs/async-await: 1.3.4 => 1.3.4
      @tarojs/components: 1.3.4 => 1.3.4
      @tarojs/components-rn: 1.3.4 => 1.3.4
      @tarojs/plugin-babel: 1.3.4 => 1.3.4
      @tarojs/plugin-csso: 1.3.4 => 1.3.4
      @tarojs/plugin-sass: 1.3.4 => 1.3.4
      @tarojs/plugin-uglifyjs: 1.3.4 => 1.3.4
      @tarojs/redux: 1.3.4 => 1.3.4
      @tarojs/redux-h5: 1.3.4 => 1.3.4
      @tarojs/router: 1.3.4 => 1.3.4
      @tarojs/taro: 1.3.4 => 1.3.4
      @tarojs/taro-alipay: 1.3.4 => 1.3.4
      @tarojs/taro-h5: 1.3.4 => 1.3.4
      @tarojs/taro-redux-rn: 1.3.4 => 1.3.4
      @tarojs/taro-rn: 1.3.4 => 1.3.4
      @tarojs/taro-router-rn: 1.3.4 => 1.3.4
      @tarojs/taro-swan: 1.3.4 => 1.3.4
      @tarojs/taro-tt: 1.3.4 => 1.3.4
      @tarojs/taro-weapp: 1.3.4 => 1.3.4
      @tarojs/webpack-runner: 1.3.4 => 1.3.4
      eslint-config-taro: 1.3.4 => 1.3.4
      eslint-plugin-taro: 1.3.4 => 1.3.4
      nerv-devtools: ^1.4.3 => 1.4.3
      nervjs: ^1.4.3 => 1.4.3
      react: 16.3.1 => 16.3.1
      react-native: 0.55.4 => 0.55.4

dxhuii avatar Jun 26 '19 03:06 dxhuii

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

taro-bot avatar Jun 26 '19 03:06 taro-bot

CC @Pines-Cheng

taro-bot avatar Jun 26 '19 06:06 taro-bot

报错还是挺详细的:"message":"Cannot find entry file index.js in any of the roots:

URL path 改为 rn_temp/index.js 即可。

Pines-Cheng avatar Jun 26 '19 06:06 Pines-Cheng

报错还是挺详细的:"message":"Cannot find entry file index.js in any of the roots:

URL path 改为 rn_temp/index.js 即可。

project.ext.react = [
    entryFile: "rn_temp/index.js"
]

修改了这里,还是不行,还提示404

dxhuii avatar Jun 26 '19 07:06 dxhuii

升级到1.3.4后,在浏览器输入http://127.0.0.1:8081/rn_temp/index.bundle?platform=android&dev=true构建bundle也是失败的,之前在rn_temp没删除node_modules还可以

yikalosi avatar Jun 26 '19 08:06 yikalosi

报错还是挺详细的:"message":"Cannot find entry file index.js in any of the roots:

URL path 改为 rn_temp/index.js 即可。

安卓的还得把 rn_temp 把这个生成目录移到 taro-native-shell 他下面吗?IOS不用移,可以跑起来,安卓应该也不用吧。

dxhuii avatar Jun 26 '19 09:06 dxhuii

报错还是挺详细的:“message”:“在任何根目录中都找不到入口文件index.js: URL路径改为rn_temp / index.js即可。

安卓的还得把rn_temp把这个生成目录移到taro-native-shell他下面吗?IOS不用移,可以跑起来,安卓应该也不用吧。

应该不用吧,你现在在浏览器输入http://127.0.0.1:8081/rn_temp/index.bundle?platform=android&dev=true 显示的什么

yikalosi avatar Jun 26 '19 09:06 yikalosi

@ dxhuii

yikalosi avatar Jun 26 '19 09:06 yikalosi

@ dxhuii

显示的JS代码,终端会加载成功,但启动模拟器,就报上面的错误了。终端也会报错,找不到 index.js

dxhuii avatar Jun 27 '19 01:06 dxhuii

@Pines-Cheng

E/unknown:ReactNative: Exception in native call
    java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.

现在又报这个错误了。

dxhuii avatar Jun 27 '19 06:06 dxhuii

@Pines-Cheng 怎么运行起来的?怎么解决的?只改了android MainActivity.java 没用

kaixinfu avatar Jun 27 '19 07:06 kaixinfu

@dxhuii 这个问题我解决了,查了好多发现是1.3.0+版本的问题, 1.首先降低taro版本 npm install -g @tarojs/[email protected],最好在taro项目里install一下 2.在taro项目npm run dev:rn,又报错 找不到 app_styles,然后在taro-native-shell项目执行 yarn add stylelint stylelint-config-taro-rn stylelint-taro-rn 3.http://127.0.0.1:8081/rn_temp/index.bundle?platform=android&dev=true,这个不好使,还是报错 找不到入口,但是直接在taro-native-shell 执行react-native run-android,android竟然启动成功了 希望能帮到你

kaixinfu avatar Jun 27 '19 08:06 kaixinfu

@liukaixin01 没法降级,用了 hooks 了。希望官方可以解决这个问题,出个常见问题解决的文档。这几天遇到这个问题应该不少。

dxhuii avatar Jun 27 '19 13:06 dxhuii

+1

zhangzhenfei avatar Jun 28 '19 03:06 zhangzhenfei

这个目前有解决方案吗?

yellowkingdom avatar Jul 02 '19 02:07 yellowkingdom

这个目前有解决方案吗?

暂时没有,我已经放弃了。taro 开发RN的坑还有太多。不过开发小程序啥的,还是比较顺畅丝滑的。

我现在已经转入 uni (类VUE)的怀抱,不管性能好不好,但是开发比较顺畅,没有什么环境问题啥的问题。人家适配的还是可以的,没啥问题。跑IOS和安卓都能跑起来,基本无配置。

等以后再来尝试。

dxhuii avatar Jul 02 '19 02:07 dxhuii

这个目前有解决方案吗?

暂时没有,我已经放弃了。taro 开发RN的坑还有太多。不过开发小程序啥的,还是比较顺畅丝滑的。

我现在已经转入 uni (类VUE)的怀抱,不管性能好不好,但是开发比较顺畅,没有什么环境问题啥的问题。人家适配的还是可以的,没啥问题。跑IOS和安卓都能跑起来,基本无配置。

等以后再来尝试。

个人感觉uni那个开发app是比较简便。不过界面库那些没有taro那么好看。

yellowkingdom avatar Jul 02 '19 02:07 yellowkingdom

修改 MainApplication.java 里面的 getJSMainModuleName ,改为:rn_temp/index,最新的 react-native-shell 已修复。

    @Override
    protected String getJSMainModuleName() {
      return "rn_temp/index";
    }

Pines-Cheng avatar Jul 02 '19 03:07 Pines-Cheng

@yellowkingdom 我也想用 taro 开发。我的PC端项目就是react,做的react服务端渲染(开源的,填个仓库地址吧:react-zanpian),如果用taro 开发,很多东西我可以 复用,现在转到 vue 也是一种妥协。

dxhuii avatar Jul 02 '19 03:07 dxhuii

@Pines-Cheng 辛苦了。谢谢,我先用其他做起来,毕竟不会原生开发,有很多东西,报错了,就只能放着了,找资料,有些还找不到。 等完善了,我以后,再重构一下,换回 taro , 一直喜欢 taro

dxhuii avatar Jul 02 '19 04:07 dxhuii