titanium android runtime error box always shows wrong line number - javascript

i am developing an cross platform application in OSX mavericks environment with titanium sdk 3.3.
While debugging on android the runtime error caught always show [1,69] for line number.So i can't spot exact position of actual error.
The same environment run smoothly on IOS application.
Any one please suggest a solution.Thanks in advance.

As far as I am concerned android errors show the line of code in the final "java binary" file and not the actual line in your Titanium source code.
Maybe you should report this as a bug report to the Appcelerator team.

The Android environment appears to be less forgiving than the IOS environment when working with Titanium. Often, after I've written my app to work for IOS, I then need to fix it to work on Android. On the positive side, these always appear to be actual errors that I guess the IOS environment either assists with or doesn't find critical enough to stop the program execution. When I fix the code to work for Andriod, it almost always works for IOS as well with the need for branching.
Just because your code is working on IOS doesn't mean you don't have a bug in it. I find that the Android debugging process helps me strengthen the quality of my app as a whole. Don't ignore the error on the Android side at [1,69], there is likely an issue there. Perhaps an unassigned variable or a null object.

Titanium studio most of the time won't show us the exact line number in our code. This holds for both iOS and Android. Other commenters have shared their thoughts about the reasons behind. I accepted that this is the price I have to pay for close to native experience. (at least for now)
The best solution I found to work like this, is to learn how to use the debugger in Titanium studio. You can add the Debug Perspective in the upper right corner with the Open perspective button. This will give you a Studio layout tuned for debugging. I use this view to fix complex problems.

Related

WebkitSpeechRecognition Returning Network Error in Electron

Recently (in the past 1.5 weeks) the javascript library WebkitSpeechRecognition has refused to work properly. I've tested other electron applications that utilize the library (smart-mirror by evan cohen) and have run into issues with those.
It throws network errors under every circumstance I've tested it. The library seems to work fine in standard browser environments but I can't seem to get it to work with electron. Does anybody have any experience in wrestling with this?
It seems that Google has removed this feature for electron. See this discussion.
Configure your own Google Speech API credentials using https://console.developers.google.com and then set them on your system's environment variables. I had the same issue and got it working with this way. Make sure to restart your system after configuring the environment variables. Sometimes they don't get into affect immediately.
Please refer for more detailed steps: https://docs.smart-mirror.io/docs/howto/how_to_obtain_chromium_speech_keys.html
GOOGLE_API_KEY, GOOGLE_DEFAULT_CLIENT_ID, GOOGLE_DEFAULT_CLIENT_SECRET set their value to Key, ClientID and ClientSecret respectively.
On some Windows PC's Speech Recognition will work in Edge but not Chrome. On another PC, seemingly with same software versions, it will not work at all and give NETWORK error. It's nice when it works, but I don't see how they expect to get any developers for it. I am developing a free word learning app, not commercial.

React Native behavior different in simulator / on device / with or without Chrome debugging

I'm building a React Native app (currently iOS only) and I found a very nasty bug that only manifests itself when 1.) running on a real device, and 2.) running without Chrome debugging. (Ouch, right?)
I'm using react-native-router-flux with tabs and when I tap on a button that loads a new tab route (Actions.tabRouteName), the screen goes blank. As I said, it works fine in the simulator, and also, on the device when I enable Chrome debugging.
Other things I tried: running on another device, reloading JS, rebuilding app in Xcode.
Any reason the behavior would be different in these different run cases?
Thank you.
Update: This appears to have something to do with animations and route switching. I posted more details in this Github issue. I also found anecdotal support for the idea that other people are encountering similar issues with debugging in this Github issue.
Any reason the behavior would be different in these different run cases?
It's because when you use remote debugging in Chrome, it practically runs the RN app in the browser (it then uses the V8 JavaScript engine) and communicates with the simulator (or device) through WebSockets. When it runs without remote debugging enabled, it uses JavaScript Core. There are many differences between these environments and these can cause inconsistencies, so don't rely much on running your app only with JS debugging enabled, it can give you false errors or hide errors that would actually cause problems on a real device.

setInterval in Android Default Browser on Galaxy S4 (Android 4.2.2)

We just got hold of a Samsung Galaxy S4 for testing our mobile website (running latest Touch-Wiz Android 4.2.2 - build JDQ39).
Straight away we noticed some major issues in our site. After some investigation, I discovered that this seems to be due to window.setInterval(fn, repeatInterval) not repeating, and only calling the passed function once.
Please note, there probably isn't a problem with our usage of setInterval, as our code works on all our other devices (lots), the chrome browser on the same device, and on desktop browsers.
I've searched, but can't find any mention of this problem. It seems bizarre to me that such a major bug would not have generated more noise.
My question is: Has anyone else seen this problem? Is it the default browser on 4.2.2, or a Touch-Wiz specific problem? Did you find an elegant work-around?
I've come up with a work-around using self-perpetuating setTimeout(s) but it's a bit nasty, and I'd rather not have to do it like that.
Turns out it wasn't actually setInterval's fault at all. Weirdly enough eval.call(window, 'some js'); seems to stop all intervals from working on this particular browser. Really don't understand how. This is the only phone we've seen it on - it doesn't happen on the stock browser on the S3 (Android 4.2.1).
P.S. The only reason we're doing eval.call is to allow make banner ads which use document.write to add scripts in a one page dynamic loading app. I'd much rather it wasn't there.

How to debug web app on windows mobile (7 and later) [duplicate]

I'm not a Windows Phone developer, and I want as little to do as possible with anything related to Microsoft. Nonetheless, I need to get my mobile web app running properly on Windows Phone 7. What debugging tools are available for the platform? Something like the Webkit developer tools or Firebug would be ideal, either from the phone itself or more likely, remotely debugging from my computer.
If such a thing doesn't exist, I'd settle for being able to read Javascript error messages, and view the contents of variables using alert() or similar. At this point, all I know is that my JS is failing: I don't know where or why, let alone how to fix it.
My dev computer is running OS X, and I'd really like to be able to use these tools from OS X if possible. Assuming that debugging tools exist (which I really hope they do) are they designed for Windows only? If so, does anyone know how well they would work with Wine or similar?
EDIT: I have a physical Windows Phone 7 device, so I can use that. However, alert() doesn't seem to be working, which is why I'm posting this question. Does alert() normally work on the WP7 browser?
You'll likely find the Mobile Perf Bookmarklet to be the easiest all-in-one tool for testing any mobile device.
Works well on the iPhone/iPad/Samsung Galaxy Tab in my testing so far.
Quote:
It displays a menu with links that load other bookmarklets including Firebug Lite, Page Resources, DOM Monster, SpriteMe, CSSess, and Zoompf.
Unless you have a Windows Phone 7 device, you will need to run Windows in BootCamp and install the Windows Phone Developer Tools in order to test in IE on the emulator. I don't know about Whine, but I ran into major problems trying to test in Parallels - so based on my experience, I suggest keeping it as simple as possible.
There is no console in IE on the phone, so you will need to use alert, like you suggested, or just write text to a div on your page as a custom console.
If you really want to code in OS X (which I definitely understand), using a separate machine for testing IE in the WP7 emulator is going to be your best bet.
EDIT: I just tested alert and it did work fine on my Windows Phone. My guess is that a syntax error is preventing it from calling.
The following may be interesting
Simple IE debug tool for Windows Phone
Supports
Html traversing
Html node styles, properties, metrics
Reading console output
Executing js on device side from console (including intellisense)
Dynamic script injection - ability to debug live sites
Not supported
js breakpoints
Just wanted to add a note to say that full JavaScript debugging is possible now with Windows Phone 8.1 and Visual Studio 2013 Update 2. Full details are available at:
http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/04/diagnosing-mobile-website-issues-on-windows-phone-8-1-with-visual-studio.aspx
I realize that this doesn't help the versions referenced in the original question (WP7), but I'm hoping this will help people who may find this question and are running a more recent version.
Something that has worked for me, is to test my mobile pages through the Windows Vista built-in Internet Explorer browser.
It comes with a script debugger ( which you have to enable in Advanced Options tab through the Internet Options menu ), and it seems that it gets really close to the Internet Explorer Mobile implementation.
Another tip would be, that, instead of using window.alerts, you can also use document.write or set output to a div content.
I'm using this hack to have console.log send info back to the server (it uses window.fetch, which I'm polyfilling, but could use xhr instead) https://gist.github.com/wheresrhys/bf93057ee3a594454582

How can I know if a Javascript exception occurred in a PhoneGap application? (Android)

How can I know if a Javascript exception occurred in a PhoneGap application?
I'm using HTC Desire Z and Android 2.2.
I don't see anything in logcat and jsconsole.com does not seem to support exception transporting.
Using console.log to trac every exception is bit hard. Is there a solution for this or is this just how it is with Phonegap?
EDIT: It seems to be possible to capture at least some of exceptions with some really hacky wrappers. This some times can put you on the right track, but probably has some serious side effects and it won't certainly capture all the exceptions.
Uncaught exceptions should show up in logcat - at least the message and line number.
Otherwise you don't have many options. window.onerror does not work in Android AFAIK.
From a recent post from the PhoneGap blog:
It’s a mobile browser! How am I
supposed to debug it! The answer is
that you aren’t. You are going to
debug your HTML, CSS, and JavaScript
app in a desktop browser. The trick is
to remove any dependencies that you
have on PhoneGap before debugging.
http://www.phonegap.com/2011/05/18/debugging-phonegap-javascript/
Only if the desktop browser would work exactly like the mobile one...
Is your question about logging the exceptions or about debugging them during development?
I'm not sure about the best way of logging them, but to debug them you can use Weinre.
I just wrote about Weinre on another very similar question ( https://stackoverflow.com/a/9252262/172973 )
Basically it's a remote javascript debugger for phonegap. You can either setup your own Weinre server, or use the one at http://debug.phonegap.com/

Categories

Resources