Skip to content

Error when running on real android device #2140

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
DavidBabel opened this issue Oct 17, 2016 · 21 comments
Closed

Error when running on real android device #2140

DavidBabel opened this issue Oct 17, 2016 · 21 comments
Labels

Comments

@DavidBabel
Copy link

DavidBabel commented Oct 17, 2016

Hey,

I don't know if i'm doing something wrong, but when i try to run a very basic app on a device with :

tns livesync android --watch

Then app install and run well, but the console spam (a lot) this error, making debug very difficult :

https://gist.github.com/DavidBabel/b595ef8d3b9f5e064ae804dbf9aff5eb

My device is a serrano LTE (samsung galaxy S4 mini) running a 6.0 CyanogenMod, and here are my Nativescript components versions :

https://gist.github.com/DavidBabel/fb9283040ca891f1873f503cb6d7cd3a

Am i doing something wrong ?
Thanks.

@matart15
Copy link

Hard to tell without looking the code. Somewhere in your code or plugin trying to convert not json formatted string into json.

something similar : NativeScript/android#404

@DavidBabel
Copy link
Author

Thanks for your answer, the problem is present on the very start of application developpement, even if i do :

tns create test --template tns-template-blank
tns platform add android
tns livesync android --watch

If i look more in detail on the error i mentioned before, it looks like it crash on parsing something like html code.
I read the similar issue answer from your link, but don't figure it out.

@matart15
Copy link

If its parsing html it is possible your backend sending html not json.
Any backend service involved?

Can you create simple github project to reproduce the problem?.

@dtopuzov
Copy link
Contributor

Can you please test on emulator or other device in order to isolate the issue.
Unfortunately we have no such device and steps you listed works on emulators and devices we have.
Btw, I can't see how we access JSON with tns-template-blank. Are you sure it is reproducible with blank template?

@DavidBabel
Copy link
Author

DavidBabel commented Oct 18, 2016

Yes 100% sure for reproductibility with blank template.
I hoped it could be a known problem easy to solve.

I don't think a github project will help, since it seems to be very device related. Just for info, here are the device specs http://i.imgur.com/WajgLsy.png.
It works fine on emulator.

I have no idea for a backend service but the spammy logs are present in "run" & "livesync", and continue even if i close the app with long press on home.

@DavidBabel
Copy link
Author

DavidBabel commented Oct 18, 2016

An easy workaround is launching the app with :

tns livesync android --watch | grep -v System.err:

But in this case, it's possible to miss some real errors.

@petekanev
Copy link
Contributor

@DavidBabel does the problem occur for you if you do just tns create testApp without passing in template arguments?

@DavidBabel
Copy link
Author

Yes it does

@danieloprado
Copy link

same error with my redmi 2:

W/dalvikvm(24921): in Lcom/tns/Runtime;.callJSMethodNative:(IILjava/lang/String;IZ[Ljava/lang/Object;)Ljava/lang/Object; (CallIntMethodA) I/dalvikvm(24921): at com.tns.Runtime.callJSMethodNative(Native Method) I/dalvikvm(24921): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:865) I/dalvikvm(24921): at com.tns.Runtime.callJSMethodImpl(Runtime.java:730) I/dalvikvm(24921): at com.tns.Runtime.callJSMethod(Runtime.java:716) I/dalvikvm(24921): at com.tns.Runtime.callJSMethod(Runtime.java:697) I/dalvikvm(24921): at com.tns.Runtime.callJSMethod(Runtime.java:687) I/dalvikvm(24921): at com.tns.Runtime.callJSMethodNative(Native Method) I/dalvikvm(24921): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:865) I/dalvikvm(24921): at com.tns.Runtime.callJSMethodImpl(Runtime.java:730) I/dalvikvm(24921): at com.tns.Runtime.callJSMethod(Runtime.java:716) I/dalvikvm(24921): at com.tns.Runtime.callJSMethod(Runtime.java:697) I/dalvikvm(24921): at com.tns.Runtime.callJSMethod(Runtime.java:687) W/ErrorReport( 998): org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject W/ErrorReport( 998): at org.json.JSON.typeMismatch(JSON.java:111) W/ErrorReport( 998): at org.json.JSONObject.<init>(JSONObject.java:159) W/ErrorReport( 998): at org.json.JSONObject.<init>(JSONObject.java:172) chromium: [INFO:library_loader_hooks.cc(116)] Chromium logging enabled: level = 0, default verbosity = 0 I/BrowserStartupController(25262): Initializing chromium process, renderers=0

@blagoev
Copy link
Contributor

blagoev commented Oct 24, 2016

Since you are using CyanogenMode 13 I guess you can enable root permisstions in adb shell
Can you do these command in shell

adb shell
su
setprop nativescript.verbose.logging true

# verify that the property is set
getprop nativescript.verbose.logging


#exit root
exit 

# redirect adb logcat to a file
logcat -c && logcat > /data/local/tmp/mylog.log

# start you app and make it crash

# then press CTRL + C on the logcat command above to return to shell

#exit adb shell
exit

adb pull /data/local/tmp/mylog.log

then upload the mylog.log to pastebin or github gist or somewhere else (the file will be big)
and send us the link.

these steps will enable logging of every method {N} is making to and from java so we can identify what is being called.

cheers

@blagoev
Copy link
Contributor

blagoev commented Oct 24, 2016

Also you can try doing it from within your app code by calling this method as the very first Javascript statement

enableVerboseLogging();

then you can check logcat to see that indeed {N} is outputing very verbose messages for the app invocations.

The above steps are still relevant so try both ways maybe

cheers

@danieloprado
Copy link

Thank you for the feedback, I'll try again and post the log here.
Bu I´m not using CyanogenMode, I´m using the current stable rom of Miui:
http://en.miui.com/download-261.html#371

@danieloprado
Copy link

@danieloprado
Copy link

screenshot_2016-10-27-20-48-47-877_com android settings

@petekanev
Copy link
Contributor

petekanev commented Oct 28, 2016

The actual error which is causing the crash ->

JNI WARNING: can't call Landroid/os/BaseBundle;.getInt on instance of Landroid/os/Bundle; (CallIntMethodA)
W/dalvikvm(  528): in Lcom/tns/Runtime;.callJSMethodNative:(IILjava/lang/String;IZ[Ljava/lang/Object;)Ljava/lang/Object; (CallIntMethodA)

It's an error that has been reported before by other Xiaomi REDMI 2 (4.4.4) users. Check out the following conversation to see if anything there can help solve your issue -> NativeScript/android#445 (comment)

@danieloprado
Copy link

danieloprado commented Oct 28, 2016

But I've tried to run 'tns run android --compileSdk 19' but exit with an errror:

https://gist.github.com/danieloprado/bde536c52c3c8c2c9da43bd0aad1c481

Same as: NativeScript/NativeScript#2914
But I'm trying to compile the default angular2 template with no modifications.

@Plamen5kov
Copy link
Contributor

Hi @danieloprado,
our minimum compileSdk version is 21, so you wont be able to build with compileSdk 19.

@danieloprado
Copy link

danieloprado commented Nov 14, 2016

Hi @Plamen5kov, Thanks for your answer.

So native doesn't support 4.4.4 kikat or lower, because I´m trying to run the statup app.

@petekanev
Copy link
Contributor

Hey @danieloprado
You can freely build Android Apps for Android devices running on API Level as low as 17, and you can build the packages with compileSdk as low as 21.

For example you can deploy an app on a phone API 19 even when you build the package with Build-tools 25 (compileSdk 25). Now, it is the developer's responsibility to handle differences in API levels accordingly, but that should not be necessary in 99% of the cases when writing NativeScript.

The core-modules that are available with every NativeScript application and they should be more than enough for your next cool app's needs.

@danieloprado
Copy link

But I'm trying to run the angular2 template with no modifications. and the first error "callJSMethodNative" ocurred in the core of application and I no be able to run the app in a phone with android 4.4.4 or lower

@slavchev
Copy link

Hi @DavidBabel @danieloprado @matart15

I am closing this issue because it is android-runtime related so I moved it to NativeScript/android#628.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants