p-3 / tic-tac-toe

Nativescript - Tic Tac Toe game example
19 stars 5 forks source link

Crash #2

Closed newnewcoder closed 7 years ago

newnewcoder commented 7 years ago

I clone this project and run command below:

cd tic-tac-toe
npm install
tns run android

it is built success but crash when running.

I get exception message below:

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5406)
    at android.app.ActivityThread.-wrap2(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
    at com.tns.Module.bootstrapApp(Module.java:311)
    at com.tns.Runtime.run(Runtime.java:498)
    at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
    ... 8 more
Caused by: com.tns.NativeScriptException: Failed to find module: "./", relative to: app//
    at com.tns.Module.resolvePathHelper(Module.java:146)
    at com.tns.Module.bootstrapApp(Module.java:309)
    ... 12 more

How can I fix this?

My node version is v8.4.0, tns version is 3.1.3

newnewcoder commented 7 years ago

I think I know what went wrong.

Maybe missing a file package.json.

I add a package.json to folder app like below:

{
    "main": "main.js",
    "name": "tic-tac-toe",
    "version": "3.0.0"
}
p-3 commented 7 years ago

Thanks for this. I am going to check on this coming weekend.

I can simultaneously update the project to ns 3 from ns 2 which can solve some compatibility issues.

p-3 commented 7 years ago

I have upgraded the project to NativeScript 3.x and I would appreciate if @newnewcoder can try if it works for you now.

newnewcoder commented 7 years ago

I pull this project, and try tns run android

then I get the exception below:

Exception in thread "main" java.io.IOException: File already exists. This may lead to undesired behavior.
Please change the name of one of the extended classes.
/Users/Pinky/Documents/nativescriptWorkspace/tic-tac-toe/platforms/android/src/main/java/com/tns/gen/android/content/BroadcastReceiver_frnal_ts_helpers_l58_c38__BroadcastReceiver.java
        at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:60)
        at org.nativescript.staticbindinggenerator.Main.main(Main.java:15)
:asbg:generateBindings FAILED

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/Pinky/Documents/nativescriptWorkspace/tic-tac-toe/platforms/android/build-tools/android-static-binding-generator/build.gradle' line: 251

* What went wrong:
Execution failed for task ':asbg:generateBindings'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 11.05 secs
Unable to apply changes on device: emulator-5554. Error is: Command ./gradlew failed with exit code 1.
Executing after-watch hook from /Users/Pinky/Documents/nativescriptWorkspace/tic-tac-toe/hooks/after-watch/nativescript-dev-typescript.js

And I try tns run ios

Does not work either:

Searching for devices...
Executing before-liveSync hook from /Users/Pinky/Documents/nativescriptWorkspace/tic-tac-toe/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-prepare hook from /Users/Pinky/Documents/nativescriptWorkspace/tic-tac-toe/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.4.2
Preparing project...
Project successfully prepared (iOS)
Successfully transferred all files.
Refreshing application...
Successfully synced application org.nativescript.DiaLog on device F7AC41B2-D74E-4B5E-AE58-5DCCDB621155.
Executing before-watch hook from /Users/Pinky/Documents/nativescriptWorkspace/tic-tac-toe/hooks/before-watch/nativescript-dev-typescript.js
Found peer TypeScript 2.4.2
objc[69460]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x11c364998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x11c189d38). One of the two will be used. Which one is undefined.
1   0x107dd733c -[TNSRuntime executeModule:referredBy:]
2   0x10797c489 main
3   0x10bd9068d start
undefined:7:68: JS ERROR TypeError: undefined is not an object (evaluating 'b.prototype')
Sep  5 21:18:06 PinkydeMacBook-Air com.apple.CoreSimulator.SimDevice.F7AC41B2-D74E-4B5E-AE58-5DCCDB621155.launchd_sim[69103] (UIKitApplication:org.nativescript.DiaLog[0xad10][69460]): Service exited due to Segmentation fault: 11
9:18:07 PM - Compilation complete. Watching for file changes.
p-3 commented 7 years ago

Do you get same message with "tns build android" / "tns build ios" @newnewcoder ? And do you get any warnings with "tns doctor" ?

newnewcoder commented 7 years ago

Yes, I get the same message with tns build android and tns build ios. And get no warning with tns doctor.

p-3 commented 7 years ago

what do you get if you run "tns info"? And does newly created apps work on you machine ( "tns create testapp --ng" & "run tns run ios/android" )?

newnewcoder commented 7 years ago

Thanks for your suggestion.

When I tried tns info & tns create testapp --ng & run tns run ios/android, I found tns has insufficient permission, which causes the error.

I reinstalled node using nvm instead of using brew, and reinstalled nativescript again. problem solved.

Thanks again!!

p-3 commented 7 years ago

I'm glad that it solved for you, and thanks for reporting back. :star2: