nativescript-cli icon indicating copy to clipboard operation
nativescript-cli copied to clipboard

Unable to preview android 'hello world' app --android

Open empirebattles opened this issue 3 years ago • 3 comments

I was following the 'tutorial/instructions' for creating a new project, from template. Used the command ns create HelloWorld --template @nativescript/template-hello-world-ts Did clean, and then did preview. Everything looks to work correctly, except when it tries to open on my device, it crashes. I believe it is due to the line that talks about local plugin is 8.0.0 and preview app is only 6.5.0.... but i have yet to successfully figure out how to run things locally (I can utilize the online playground without issue). If you have any ideas what is causing this, or more specifically how to fix it, please let me know. I'm just trying to see how to start a project at this point, and would like to be able to test along the way as i learn. Slightly concerning if the preview app doesn't even work with the included hello world tutorials.

This is the cmd log:

`Platform android successfully added. v8.0.0 Preparing project... webpack is watching the files...* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * asset vendor.js 5.66 MiB [emitted] (name: vendor) (id hint: defaultVendor) * asset bundle.js 436 KiB [emitted] (name: bundle)plugins with native dependencies. * Entrypoint bundle 6.09 MiB = vendor.js 5.66 MiB bundle.js 436 KiBtns preview. Please, use $ tns run command instead. * runtime modules 25 KiB 13 modules * orphan modules 356 bytes [orphan] 6 modules * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * modules by path ./node_modules/@nativescript/core/ 1.41 MiB 164 modules modules by path ./node_modules/css-tree/ 317 KiB 113 modules modules by path ./app/ 126 KiB 8 modules modules by path ./node_modules/source-map/lib/.js 36.3 KiB 6 modules modules by path ./node_modules/reduce-css-calc/dist/ 131 KiB modules by path ./node_modules/reduce-css-calc/dist/lib/.js 11.1 KiB 3 modules modules by path ./node_modules/reduce-css-calc/dist/.js 120 KiB 2 modules modules by path ./node_modules/postcss-value-parser/lib/.js 11.8 KiB 5 modules modules by path ./node_modules/mdn-data/css/*.json 242 KiB 3 modules ./node_modules/tslib/tslib.es6.js 10.5 KiB [built] [code generated] external "~/package.json" 42 bytes [optional] [built] [code generated] ./node_modules/css-unit-converter/index.js 2.57 KiB [built] [code generated] webpack 5.28.0 compiled successfully in 2903 ms Webpack compilation complete. Watching for file changes. Updating runtime package.json with configuration values... Project successfully prepared (android) Start sending initial files for device Galaxy S9+ (787634b7-220b-419c-b209-89bf92a15a3c). Successfully sent initial files for device Galaxy S9+ (787634b7-220b-419c-b209-89bf92a15a3c). Issues checking in progress... File change detected. Starting incremental webpack compilation... assets by status 6.09 MiB [cached] 2 assets Entrypoint bundle 6.09 MiB = vendor.js 5.66 MiB bundle.js 436 KiB cached modules 2.27 MiB (javascript) 25 KiB (runtime) [cached] 347 modules javascript modules 506 bytes ./app/@nativescript_webpack_virtual_entry_typescript 236 bytes [built] ./app/ sync .(xml|js|(?<%21d.)ts|s?css)$ 270 bytes [built] webpack 5.28.0 compiled successfully in 919 ms Webpack compilation complete. Watching for file changes. Issues checking in progress... No issues found. Local plugin @nativescript/core differs in major version from plugin in preview app. The local plugin has version ~8.0.0 and the plugin in preview app has version 6.5.0. Some features might not work as expected.


  •                                                                                                                               *
    
  • In the app are used one or more NativeScript plugins with native dependencies. *
  • Those plugins will not work while building the project via $ tns preview. Please, use $ tns run command instead. *
  •                                                                                                                               *
    


  •                                                                                                           *
    
  • The platforms/android folder appears to be invalid. If the build fails, run 'ns clean' and rebuild the app. *
  •                                                                                                           *
    

Preparing project... Updating runtime package.json with configuration values... Project successfully prepared (android) Start sending initial files for device Galaxy S9+ (787634b7-220b-419c-b209-89bf92a15a3c). Successfully sent initial files for device Galaxy S9+ (787634b7-220b-419c-b209-89bf92a15a3c). LOG from device Galaxy S9+: An uncaught Exception occurred on "main" thread. Unable to start activity ComponentInfo{org.nativescript.preview/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed Error: Failed to load component from module: app-root

StackTrace: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.preview/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed Error: Failed to load component from module: app-root at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3654) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3806) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100) Caused by: com.tns.NativeScriptException: Calling js method onCreate failed Error: Failed to load component from module: app-root at com.tns.Runtime.callJSMethodNative(Native Method) at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286) at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173) at com.tns.Runtime.callJSMethod(Runtime.java:1160) at com.tns.Runtime.callJSMethod(Runtime.java:1138) at com.tns.Runtime.callJSMethod(Runtime.java:1134) at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:20) at android.app.Activity.performCreate(Activity.java:7963) at android.app.Activity.performCreate(Activity.java:7952) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3629) ... 11 more`

empirebattles avatar Apr 10 '21 21:04 empirebattles

I think the preview app currently does not support "@nativescript/core" : "8.0.0" yet.

You could connect your android device to your computer via USB and run the app with ns run android

janoshrubos avatar Apr 12 '21 08:04 janoshrubos

NativeScript Playground app looks abandoned. Currently its version marked 24 july 2019...

phoenixweiss avatar May 08 '21 17:05 phoenixweiss

Then they should update all the beginner documentation or fix it!!!!! instead of wasting my time!!!

gfmoore avatar Jun 08 '21 14:06 gfmoore

NativeScript Preview 2.0 has been released: https://preview.nativescript.org/

rigor789 avatar Jan 20 '23 17:01 rigor789