[Q] Writing an app, works in emulator, crashes on device - Java for Android App Development

Hi Folks, Hopefully this is the right place for this thread. I don't get over here very often so I'm guessing right now.
I wrote an app for my phone (Sprint Galaxy SIII) in Eclipse to control a IOIO (not terribly important to know for this question). I run the app in the emulator and it fires up just fine, but when I run it on my phone (with supposedly the same settings as the emulator--Android version, AP level, etc) it crashes on startup, saying "Unfortunately, <My App> has stopped".
Since it works in the emulator I can't track LogCat to check for errors, so I have no idea where to start looking for the cause. It only crashes on my actual device. My questions are as follows:
1) What would cause an app to work in the emulator but fail to start up in a device with (supposedly) the same settings?
2) Where can I go to look for errors on my phone (if possible) that might point me to the problem?
Thanks!
Matt

DerStrom8 said:
Hi Folks, Hopefully this is the right place for this thread. I don't get over here very often so I'm guessing right now.
I wrote an app for my phone (Sprint Galaxy SIII) in Eclipse to control a IOIO (not terribly important to know for this question). I run the app in the emulator and it fires up just fine, but when I run it on my phone (with supposedly the same settings as the emulator--Android version, AP level, etc) it crashes on startup, saying "Unfortunately, <My App> has stopped".
Since it works in the emulator I can't track LogCat to check for errors, so I have no idea where to start looking for the cause. It only crashes on my actual device. My questions are as follows:
1) What would cause an app to work in the emulator but fail to start up in a device with (supposedly) the same settings?
2) Where can I go to look for errors on my phone (if possible) that might point me to the problem?
Thanks!
Matt
Click to expand...
Click to collapse
Only log could tell you the possible reasons.
Install catalog and look for the error log
Sent from my A0001 using Tapatalk 2

Vivek_Neel said:
Only log could tell you the possible reasons.
Install catalog and look for the error log
Sent from my A0001 using Tapatalk 2
Click to expand...
Click to collapse
Thanks Vivek_Neel. I tried a couple of log viewer apps but they all require superuser access for use on Android 4.1+. I forgot to add it to my profile, but I currently have a Galaxy SIII running Android 4.4.2.
Any other suggestions? I'd rather not root my phone if I don't have to.
Thanks,
Matt

DerStrom8 said:
Thanks Vivek_Neel. I tried a couple of log viewer apps but they all require superuser access for use on Android 4.1+. I forgot to add it to my profile, but I currently have a Galaxy SIII running Android 4.4.2.
Any other suggestions? I'd rather not root my phone if I don't have to.
Thanks,
Matt
Click to expand...
Click to collapse
Running the app on your phone with it plugged in to a pc and eclipse open should mean that eclipse catches the log, no root access needed, you would need to allow adb debugging though. If it doesn't work with eclipse I know for definite that it works with Android Studio.

Jonny said:
Running the app on your phone with it plugged in to a pc and eclipse open should mean that eclipse catches the log, no root access needed, you would need to allow adb debugging though. If it doesn't work with eclipse I know for definite that it works with Android Studio.
Click to expand...
Click to collapse
Eclipse doesn't seem to recognize my phone. It only brings up the emulator as an available device. Perhaps I should dig more into the cause of that first. You're saying if I load the app on my phone while connected to the PC it'll still show up in the logcat? That would be a huge help if that's the case!

DerStrom8 said:
Eclipse doesn't seem to recognize my phone. It only brings up the emulator as an available device. Perhaps I should dig more into the cause of that first. You're saying if I load the app on my phone while connected to the PC it'll still show up in the logcat? That would be a huge help if that's the case!
Click to expand...
Click to collapse
It should do - worked this way around a year ago when I was using eclipse myself before jumping ship to AS.

You might want to handle uncaught exceptions and either debug, write to a file or what ever is the best way for you.
You can see an implementation example for handling uncaught exceptions here: http://stackoverflow.com/questions/8943288/how-to-implement-uncaughtexception-android.
Please note that some crashes are not caught using this technique so you'll need to use the above mentioned methods to view logcat.
If you have root on your device, install a logcat viewer application. most likely that filtering the display by your package name (or parts of it) we'll lead you to the error cause.

Thanks everyone for the help, I have found the solution. Eclipse wasn't recognizing my phone because apparently the driver was no longer installed (I thought I had installed it a long time ago, but that must have been on my laptop--I'm on my desktop now). I installed it and Eclipse found the phone no problem. I loaded the app while watching LogCat and found the following:
java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10211 nor current process has android.permission.BLUETOOTH.
Click to expand...
Click to collapse
Well that was embarrassing! Added the Bluetooth permissions to the app et voila! The app works just fine.
Thanks for your time!
Matt

DerStrom8 said:
Thanks everyone for the help, I have found the solution. Eclipse wasn't recognizing my phone because apparently the driver was no longer installed (I thought I had installed it a long time ago, but that must have been on my laptop--I'm on my desktop now). I installed it and Eclipse found the phone no problem. I loaded the app while watching LogCat and found the following:
Well that was embarrassing! Added the Bluetooth permissions to the app et voila! The app works just fine.
Thanks for your time!
Matt
Click to expand...
Click to collapse
:laugh::laugh:
Haha glad you got it sorted!

Related

app got FC in phone, but works in Emulator

Hi there,
I wrote a small program for my phone, and it runs well on the android emulator. But when I install it on my phone, it got FC.
This program requires root authorization. My phone is rooted of course.
I just started learning the android programing. So wondering is there any method to debug on phone?
Thanks a lot.
geeti said:
Hi there,
I wrote a small program for my phone, and it runs well on the android emulator. But when I install it on my phone, it got FC.
This program requires root authorization. My phone is rooted of course.
I just started learning the android programing. So wondering is there any method to debug on phone?
Thanks a lot.
Click to expand...
Click to collapse
Logcat is your friend or try the tools from the SDK
First off, make sure the phone isn't just waiting for the debugger to attach... this has confused me in the past (and I've closed out before the FC thing went away).
Otherwise it might be a permission you forgot to give the app, something simple. (Usually it's the simple stuff, actually.)
You should be able to debug the app using eclipse.
Other than that logcat is really an invaluable tool for crashes. If you can't decipher it yourself, feel free to upload it here and we'll take a look.
geeti said:
Hi there,
So wondering is there any method to debug on phone?
Thanks a lot.
Click to expand...
Click to collapse
The debugger should work on your phone exactly the same way as it does in the emulator. Just make sure you have USB Debugging turned on.
The most common reason for FCs is that the app does not have the permission to do something. AFAIK the app does not require all the permissions when executed in the emulator. (e.g. vibration)

[Q] How to sideload apps without rooting or using a file manager app

Hey guys,
I've searched high and low in this forum and others for a solution to my problem, I have been unable to find one. I'm looking for a way to sideload apps onto a Kindle Fire so that, after the third party app has been installed, I can clear the Launcher data and the next time I start the device it boots to the setup and welcome screens like the very first boot.
The reason I want to avoid rooting or having to download a file manager app to the device is that I am planning to create a script for the process.
Any advice or links to a helpful guide?
lama1130 said:
Hey guys,
I've searched high and low in this forum and others for a solution to my problem, I have been unable to find one. I'm looking for a way to sideload apps onto a Kindle Fire so that, after the third party app has been installed, I can clear the Launcher data and the next time I start the device it boots to the setup and welcome screens like the very first boot.
The reason I want to avoid rooting or having to download a file manager app to the device is that I am planning to create a script for the process.
Any advice or links to a helpful guide?
Click to expand...
Click to collapse
Now I'm confused, on the Android Forums you said it was so you could give it to someone as a gift and you wanted to give them the "first-time use" experience. I really don't see anyone needing a script for something like this but I may be wrong.
It's more of a fun project for me than anything else, a Kindle Fire loaded with apps makes for a great and affordable gift and I have other family members who I intend to give the Kindle Fire to as a gift. But I don't want them to feel as though I've been mucking with it
lama1130 said:
It's more of a fun project for me than anything else, a Kindle Fire loaded with apps makes for a great and affordable gift and I have other family members who I intend to give the Kindle Fire to as a gift. But I don't want them to feel as though I've been mucking with it
Click to expand...
Click to collapse
I completely understand, I still think the easiest way would be to just use ES file explorer, or something similar, to install them and then just delete the app. Maybe someone here will have a different idea.
I may be confused, but couldn't youbjust build a rom with the apps loaded in and flash it?
Sent from my ADR6300 using XDA App
Twisted politiks said:
I may be confused, but couldn't youbjust build a rom with the apps loaded in and flash it?
Sent from my ADR6300 using XDA App
Click to expand...
Click to collapse
Perhaps. Can you link me to any guides on this?
Are you trying to make a script that will be run on a computer or on the Fire itself? If you're running the script on an actual device (terminal emulator, gscript, etc):
Code:
pm install /path/to/file.apk
In that case the .apk will need to be copied onto the device first. If you're running a script from a computer and have the device plugged in via USB you can use:
Code:
adb install /path/to/file.apk
...and for that one the .apk needs to be on your computer somewhere. I know 'adb install' doesn't require root. I don't remember if 'pm install' does, but I think it doesn't. Either way, you just need to get a copy of the .apks you want to install.
Cant you just reset the device to factory defaults from the settings?
iroctheworld said:
Cant you just reset the device to factory defaults from the settings?
Click to expand...
Click to collapse
That gets rid of your apps as well.
eldarerathis said:
Are you trying to make a script that will be run on a computer or on the Fire itself? If you're running the script on an actual device (terminal emulator, gscript, etc):
Code:
pm install /path/to/file.apk
In that case the .apk will need to be copied onto the device first. If you're running a script from a computer and have the device plugged in via USB you can use:
Code:
adb install /path/to/file.apk
...and for that one the .apk needs to be on your computer somewhere. I know 'adb install' doesn't require root. I don't remember if 'pm install' does, but I think it doesn't. Either way, you just need to get a copy of the .apks you want to install.
Click to expand...
Click to collapse
I don't have any experience using adb, but I'll start looking into it.

[Q] installing application

hello,
i read there are different way to install application , i wish to try to understand all the way and how they work, could you help me in this ? i am a noob but i am perfectionnist
- open the market from your rooted nook, select the app , install
- open the market from a computer , connect with your google account, select the app, install
- find the apk , download on sd card , use a file explorer to install
these are the easy ways, is there any more way to do ? thanks
c-loet said:
hello,
i read there are different way to install application , i wish to try to understand all the way and how they work, could you help me in this ? i am a noob but i am perfectionnist
- open the market from your rooted nook, select the app , install
- open the market from a computer , connect with your google account, select the app, install
- find the apk , download on sd card , use a file explorer to install
these are the easy ways, is there any more way to do ? thanks
Click to expand...
Click to collapse
Using the ADB interface.
eded333 said:
Using the ADB interface.
Click to expand...
Click to collapse
i am just in the middle of looking for that in the forum, i don't understand what it is and how it works... can't find easy explanation...
The first three steps of one of my manual tutos:
http://forum.xda-developers.com/showpost.php?p=20069222&postcount=3
Helps you get ADB running on windows.
ADB is Android Debug Bridge. It provides terminal-based interface for interacting with your phone’s file system.
And this makes a small simple script to easily connect to your device.
http://forum.xda-developers.com/showpost.php?p=20069359&postcount=14
Check my other manual tutos if you are interested in some examples of what you can do with ADB. (On my sig)
thanks eded333, i will have a close look to that. I like to understand, but i feel like my computer skills are to small to go ahead in that step. but anyway, i will try
Unless you want to use your e-ink device as a tablet, you don't want to have a market app (even Amazon) on it. Or to have mail programs. I personally prefer to use it for reading though I have a normal tablet for other stuff.
Anyways, my point is try to get used to adb way, this one is keeping your nook less bloated than anything else.
Sent from my GT-P1000 using Tapatalk 2

[ROOT][WINDOWS]FIRE 5TH GEN AUTOROOT SCRIPT. NOOB FRIENDLY! Kindle Universal?

Moved to http://forum.xda-developers.com/amazon-fire/general/root-playstore-busybox-optimize-flash-t3281804
Download link
Thread moved to http://forum.xda-developers.com/amazon-fire/general/root-playstore-busybox-optimize-flash-t3281804
Thanks a lot for this nice tool (which came in too late for myself, alas). A couple of comments:
- Could you preserve timestamps of incorporated files? It would make comparisons to existing tools easier.
- I understand that ROM size is not an issue, would it be possible to make the debloat deactivations reversible? (e.g. pm disable/hide instead of rm - if something goes wrong there would be a chance to get back functionality)
- Five minutes seem a tad on the low side - I have seen more than that in a single reboot (when cache rebuilds took place).
Nevertheless: Very nice, I hope the tool will be useful to many people unpacking Fires from their stockings!
Noob
So I can run this on the stock 5.1.1 firmware by just downloading it to the sd card and install. On home screen open and it will root and install all that is listed?
Thank you in advance
Thanks for this! I just used it on my son's brand new Fire 7" tablet. I had to modify the .sh a little to run the script in Ubuntu http://pastebin.com/C1PXnqxa
egomaster said:
So I can run this on the stock 5.1.1 firmware by just downloading it to the sd card and install. On home screen open and it will root and install all that is listed?
Thank you in advance
Click to expand...
Click to collapse
Sorry about the unclear instructions. I updated the tutorial. You run the script from your computer with your device on the homescreen. :3
glitch3yf0x said:
Sorry about the unclear instructions. I updated the tutorial. You run the script from your computer with your device on the homescreen. :3
Click to expand...
Click to collapse
Thank you for clarifying. Will give this a try.
Thanks so much for the suggestions.
- I honestly don't know what you are referring to by this or how to do that, but I'll do it if you can PM me explaining it.
- Sure! I'll do this in the next version or the next, but I promise something like it will be done. :3
-I'll time it tonight and update. The script cuts off the cache rebuilds until the very end.
Thank you, the install went perfectly, this makes the Fire 5.1.1 livable until the bootloader is unlocked. I have encounter one thing, widgets cannot be added to the homescreen. Is this an expected issue or is there something going on with my tablet I need to explore?
JaboJG said:
Thanks for this! I just used it on my son's brand new Fire 7" tablet. I had to modify the .sh a little to run the script in Ubuntu http://pastebin.com/C1PXnqxa
Click to expand...
Click to collapse
Thanks man. I really appreciate it. Your name has been added to the Thanks and i'll use a modified version based of your editing in the next release tonight.
Komet1 said:
Thank you, the install went perfectly, this makes the Fire 5.1.1 livable until the bootloader is unlocked. I have encounter one thing, widgets cannot be added to the homescreen. Is this an expected issue or is there something going on with my tablet I need to explore?
Click to expand...
Click to collapse
I think I know what the problem is. It'll be fixed with the next update, which probably will be less than two hours from now. I appoligise for the inconvenience.
It's just sitting on daemon started successfully for quite a while, is this normal?
not sure what is going on, ran the script and everything went fine. however, the device is still trying to update. it seems like updates weren't blocked or something. i never let it install the initial update though that it tries to do when you turn on the device. i never even connected it to a wifi network so not sure how it can even update
google play services refuses to install as well. not sure what is wrong but seems like there must be some bugs in this script.
knives of ice said:
not sure what is going on, ran the script and everything went fine. however, the device is still trying to update. it seems like updates weren't blocked or something. i never let it install the initial update though that it tries to do when you turn on the device. i never even connected it to a wifi network so not sure how it can even update
google play services refuses to install as well. not sure what is wrong but seems like there must be some bugs in this script.
Click to expand...
Click to collapse
That's very odd. Can you attach screenshots and such so I can look into this? Also, try the updated script I have just updated the link too.
If you continue to have problems, adb sideload to start fresh.
I believe you may be getting confused with the "Updating your apps" screen, which is normal. This is android recompiling the cache for the newly installed apps.
What's the error shown when google play doesn"t install?
Soundmotion3004 said:
It's just sitting on daemon started successfully for quite a while, is this normal?
Click to expand...
Click to collapse
That's not normal. What OS are you using? Is Android Debugging enabled on your device and did you allow the "Accept debugging from this computer?" prompt on your tablet?
glitch3yf0x said:
That's very odd. Can you attach screenshots and such so I can look into this? Also, try the updated script I have just updated the link too.
If you continue to have problems, adb sideload to start fresh.
I believe you may be getting confused with the "Updating your apps" screen, which is normal.
What's the error shown when google play doesn"t install?
Click to expand...
Click to collapse
damn, went and used the other install script for google play store and still problems
here is the error i get when it tries to update google play services
CAN'T UPDATE APP
Update for "google play services" could not be downloaded due to an error. (error retrieving information from server. [RPCS:S-7 AEC-7 OIKJ-IY4V-YMNYK]
play store is there and i can browse through it but i know from doing this on my first fire tablet that i need to update google play services. that will not update not matter what i try i get that error. rebooting no help
any idea on what i can do. it seems like i'm rooted fine supersu is there. i have no experience with adb at all
also, wasn't confused with updating apps at all. it was the FIRE screen saying software is updating to the latest version. it seemed like it updated though i have no idea how when not connected to wifi
knives of ice said:
damn, went and used the other install script for google play store and still problems
here is the error i get when it tries to update google play services
CAN'T UPDATE APP
Update for "google play services" could not be downloaded due to an error. (error retrieving information from server. [RPCS:S-7 AEC-7 OIKJ-IY4V-YMNYK]
play store is there and i can browse through it but i know from doing this on my first fire tablet that i need to update google play services. that will not update not matter what i try i get that error. rebooting no help
any idea on what i can do. it seems like i'm rooted fine supersu is there. i have no experience with adb at all
also, wasn't confused with updating apps at all. it was the FIRE screen saying software is updating to the latest version. it seemed like it updated though i have no idea how when not connected to wifi
Click to expand...
Click to collapse
The Fire logo with "Updating Apps..." is normal. :3 It should be gone after two reboots.
As for the google play problem, It sounds like you need to clear the data and relogin to google. Was there anything relating to google play on your device previously before the script? You may have to be connected to wifi for google play to download updates, if you still aren't.
glitch3yf0x said:
The Fire logo with "Updating Apps..." is normal. :3 It should be gone after two reboots.
As for the google play problem, is there anything relating to google play on your device currently? It sounds like you need to clear the data and relogin to google.
Click to expand...
Click to collapse
i haven't loaded 1 thing. i never even connected to wifi before running your script.
ok i went in and cleared everything in the google framework and play store, now when i try to open play store it just spins. will not load. any suggestions? no idea what the problem could be.
EDIT - ok finally got it. for some reason it just started working. i think there must have been a notfication that was showing which i didn't accept
Glad to hear! Usually the infinite spinning wheel means you need to accept the terms of use. :3
Everything worked fine, just one note that seems to be a side affect. I had a childs profile setup before running the script, now I cannot change settings or delete the profile.

[NOROOT] On Boot AppStarter

On Boot AppStarter
On Boot AppStarter is inspired by OnBootKodi created by Xtraordinair. (Thanks dude)
It launches your favorite application like Kodi, AppStarter, SPMC or others after FireTV's startup .
HowTo
1) Install app via sideloading
2) Launch app
3) Select your favorite app
4) Reboot
5) Your favorite app will be launched after startup automagically
Changelog
v1.0
- initial release
Source:
Bitbucket
Download
OnBootAppStarter_v1.0.apk
XDA:DevDB Information
On Boot AppStarter, Device Specific App for the Amazon Fire TV
Contributors
mirosz
Source Code: https://bitbucket.org/Mirakel/onbootappstarter/src
Version Information
Status: Beta
Current Beta Version: 1.0
Beta Release Date: 2017-06-04
Created 2017-06-04
Last Updated 2017-06-04
Sorry to say, but OnBootKodi has been blacklisted by Amazon, so it's likely your app is next.
AFTVnews.com said:
Sorry to say, but OnBootKodi has been blacklisted by Amazon, so it's likely your app is next.
Click to expand...
Click to collapse
Thanks for that info. I'll have a look at it.
Shouldn't it be bypassed by just changing the package name in apps manifest file?
How does Ama. recognize those apps? Only by checking xda or other boards or do they use an algorithm to check for those apps and report them?
EDIT: Is it possible to extract the Settings.db via adb on an unrooted device?
mirosz said:
Thanks for that info. I'll have a look at it.
Shouldn't it be bypassed by just changing the package name in apps manifest file?
How does Ama. recognize those apps? Only by checking xda or other boards or do they use an algorithm to check for those apps and report them?
EDIT: Is it possible to extract the Settings.db via adb on an unrooted device?
Click to expand...
Click to collapse
Pretty sure they just block by package name right now. I assume they just hear about these apps online and aren't actively scanning for them, but who knows. Not sure if you can mess with Settings.db on an unrooted device. Never tried.
where are the settings stored, id like to be able to push them via adb, and edit them on my pc
Is this app still working?
as of about 16 hours ago, yes.
Can you make is so that app can update over internet to change the name ever so often to avoid the blacklist?
luckily this still works. i couldnt find a way to disable the blacklist. see https://forum.xda-developers.com/showpost.php?p=73761262&postcount=15
Still working with latest update. Thank you!
Pretty sure with the source you could just make your own build/name and avoid all problems with blacklisting.
Dose this work on the latest firestick gen 2 with latest software?
jonnym12345 said:
any one elce getting problems with this after installing keep getting a message with avast ?
Click to expand...
Click to collapse
Then you will have caught one of the dangerous Android viruses and should reformat your system partition urgently!
rainman74 said:
Then you will have caught one of the dangerous Android viruses and should reformat your system partition urgently!
Click to expand...
Click to collapse
This is what I get
If i Install it using packege installer it installs then I get this malwarebytes popup & if I do a scan of device with avast avast dose not come up anything on device all safe but if i press install with avast instead of package instasller i get this pop up comes up with this if install using avast & malwarebytes pops up with this notification
Do I need wipe my device start a new?
jonnym12345 said:
Dose this work on the latest firestick gen 2 with latest software?
Click to expand...
Click to collapse
It was a few weeks back that I installed this on a FTV2S. But it worked great for me. Was a gift. So don't have immediate access to it now. But haven't heard any complain from my friends.
So yes. It still works perfectly when setup correctly. I mostly use it with AppStarter v4.0.
---------- Post added at 03:59 PM ---------- Previous post was at 03:55 PM ----------
jonnym12345 said:
This is what I get
If i Install it using packege installer it installs then I get this malwarebytes popup & if I do a scan of device with avast avast dose not come up anything on device all safe but if i press install with avast instead of package instasller i get this pop up comes up with this if install using avast & malwarebytes pops up with this notification
Do I need wipe my device start a new?
Click to expand...
Click to collapse
Uninstall this app. Then run your virus scanner again. If it passes then re-download it. Then reinstall it. And see if it does it again. If you downloaded a clean version then u shouldn't have that problem.
firedl app code for this app
292946
simple launcher appstarter v4.0
https://forum.xda-developers.com/fire-tv/themes-apps/app-root-home-launcher-replacement-app-t3118135
firedl app code 886355
let’s you set go back to your cumstom launcher home while in any app
https://forum.xda-developers.com/amazon-
fire/general/launcher-root-launcher-hijack-v2-t3561026
firedl app code 685303
can i boot directly to the my apps menu?
godlike1984 said:
can i boot directly to the my apps menu?
Click to expand...
Click to collapse
No. But if you use Appstarter 4.0 it will boot to a list of all your apps.
Seems to be blocked now on 6.2.1.2
Really need a way to be able to start Kodi without Internet connection.
mace2442 said:
Seems to be blocked now on 6.2.1.2
Really need a way to be able to start Kodi without Internet connection.
Click to expand...
Click to collapse
I changed the package name so this should work for you if it really is blacklisted now....

Categories

Resources