I'm debugging an Android app on an HTC tablet and every time I uninstall the app, the device reboots. Uninstallation also happens as part of trying a new build, so any changes to the app require a reboot before testing. This is predictably aggravating for development.
The problem sounds similar to that described here except that there's no mystery about it in my case. Uninstall => reboot. Change app and debug through Eclipse & adb => reboot. Wiping all the data on the device as suggested in the only answer to the similar problem is not desirable, especially as there's not much indication that even that poster saw it as anything other than the tech equivalent of sacrificing a chicken.
Can anyone tell me why this is happening and how to prevent it?
I'm not offering this as an answer (at least not yet) but need more space than a comment provides to brainstorm about how to investigate this
I'd be tempted to take a safe "hello world" type app and merge it into the project as its own activity. Then comment out all the real functionality from the manifest and java files. That should leave only the hello world and the resources. See if the device survives uninstalling that after a run - if not, guess you might have to suspect the resources.
This should do the commenting - or you could just remove files wholesale from the tree
find . -name "*.java" | xargs -I f sed -i 's/^/\/\//' f
(Some editors will do block comment/uncomment, emacs will do arbitrary operations on a column of a file.)
Then I'd either uncomment the skeleton of the real activity - ie, all the onCreate, onStart, etc methods with no operations in them, and restore that activity to the manifest. Or else I'd restore functional java code, but leave the activity out of the manifest. You could then incrementally add more and more functionality until you get a crash.
If you have any ndk libs or even java libs you could play a similar game with those.
You can also try to run logcat during the uninstall and see if any messages make it out before the device hangs up on you.
Oh - and a major question, is this a kernel reboot, or an android runtime restart? In the later case, adb & logcat should probably survive, and /proc/uptime will not be reset to a small number.
If you get it down to a suspect operation, it would be great if you could post a description of that - I have a similar device in my test collection and would be curious to see if it has the same apparent bug. Also HTC has a number of "Developer Evangelists" who might be a point of contact.
Related
This has nothing to do with eclipse. Every other question about logcat not displaying anything on this site is about eclipse, so far as I have found. This is not one of them.
I have an LG G3. It's rooted and bumped. It's pestering me ALL THE DAMN TIME to update (there's apparently no way to shut this off with the Verizon model). I really, really, REALLY want to use a custom ROM to end this pain. Thing turns on the screen and leaves it that way until I notice and tell it to bug me sometime within the next 24 hours.
I set it up with Skydragon, which from what I can tell is the stock ROM de-bloated and slightly modified to run faster and more efficiently.
Apparently though it has no log. I can connect to it with adb just fine. I can upload apps and run them. What I can't do is see anything at all in logcat. I even tried opening the main log device on the phone, it was empty.
My best guess is that either the kernel doesn't have logging facilities in it, which would seem stupid so I doubt it, or the logging service isn't turned on (assuming there is one). I don't see any log service file in the init.d directory (skydragon I believe uses init.d).
Anyone know what I need to do here to get logging working? I'd sort of like to stick as close to stock as possible at least for the time being. It's getting frustrating though. Either I'm constantly arguing with the system upgrader, or can't debug my apps with logs. Neither is what I'd call acceptable.
I did try asking this same question in the skydragon thread at xda but got no reply. It's been a week so I don't expect one.
Was able to get this going by selecting the stock kernel in the aurora install. With this done the expected logcat content is there. There may be a better answer, but it's yet to be provided. I'll leave this open just in case, but this be here for those searching for WTF might be going wrong needing to fix it.
First, I know this question doesn't exactly belong here, but I'll explain later why I'm asking here instead of on the specific android board.
I'm developing an app, and yesterday I had some problems with sqlite, so I went on to checking how my database looked like. Found out I didn't have the sqlite3 actually installed on my phone, so I followed this answer to install it. I got some problems with the pushing part so I tried to alter the permissions on /system to try and make it work. I basically ran "chmod 7777 /system" on an adb shell. After that I still couldn't push the sqlite to the phone, so I quit the shell and tried to open it again, but I got a no permission error. When I unlocked the phone, every possible app (including system ones) started crashing, one after the other. I freaked out and took the battery off. at that time I had the phone connected through usb to a Ubuntu pc, with no headphones connected. When I turned the phone on again everything seemed to work properly, and I managed to push the sqlite to the system folder without any problem. I thought the problem was over and moved on with debugging and developing.
When I was going home, I was listening to some music with headphones and a friend called me. I answered but couldn't hear anything. I then later discovered that since then I can't hear anything and no one can hear me too. Every other sound related function works fine, except calling. I'm not hearing even that calling beep.
So that's why I'm asking here, as it's actually a question related to developing and coding stuff. Please, if anyone knows what this might be, answer here, I have tried many things to get it working again, but none of them worked. I read it could be a headphone related issue, but that seems to occur only on some motorola phones or something. I have a Galaxy S advance, 3 or 4 months old. I have also tried to change the chmod setting again, to chmod 4755 /system, but it remains the same. I'm getting really desperate here, I don't think customer support can solve this.
As nobody ansered yet, and also I think this is a too specific error for many people to know, I'll report what I did and discovered:
I changed the permissions of all the files in the folders /system and /system/app, not recursively.
A friend later told me UNIX systems sometimes have problem with executing programs that have too many permissions
All the system applications had full 777 permissions.
So I rebooted the device many times, even made a factory reset on it, but nothing seemed to work. So I began changing the permissions again. I tried to change everything to the default permissions (I used a friend device of same model as reference), and when I changed the system/app folder permissions to 755 and rebooted, it worked again!
So for all of you who don't know exactly how chmod and permissions on UNIX works, think twice before start to mess up with it.
How do I get root access in order to reboot the emulator? How do I kill all unwanted processes along with the child process?
You have already root access to your emulator. To kill a process and all childs just use the device view in eclipse, select the emulator theere and chose which process you want to kill.
I have no idea on how to restart from code if you are looking for that. Rebooting the device should be easy: just close it and than boot it up again.
(I have the feeling I don't really get what you want...)
Most su binaries for Android depend on SuperUser.apk (available for free through the market). The su binary uses this apk to ask the user if it's ok to do whatever is being requested (and the user can opt to remember the answer). If you're using such a su, you need to also have that apk.
Once the pieces are in place, your application can spawn a process with the right arguments... something like argv[0]="/path/to/su", argv[1]="-c", argv[2]="(whatever command you want to run)", argv[3...n]=arguments to your command.
To kill a process in the command line, simply issue the following command line on the shell:
kill-9 YOUR_PID
If you know the name of the process, but not the pid, use
kill -9 $(pidof NAME_OF_PROCESS)
You can also use it on your code:
Runtime.getRuntime().exec("kill-9 YOUR_PID");
Check the man page for more details: http://unixhelp.ed.ac.uk/CGI/man-cgi?kill
ps-after rebooting i also wanted to kill all unwanted process except my specific app and its child process alone to run in emulator.
If that is really what you want to do - repurpose an android build as a generic embedded linux, then the way to go about it is to regenerate a ramdisk image (which android packs onto the kernel) containing an init.rc which launches your application rather than the android native services and (java-esque dalvik) android runtime. Rebuilding the ramdisk requires a unix-like OS and that arcane cpio command line which you can find in web search. I'd be tempted to leave the startup of ADB in there so you can debug the various things which will go wrong.
For testing purposes simply typing "stop" from the adb shell will shut down the android runtime and give you a UI-less virtual pocket linux box. There will still be some native services running but they may be more help than harm. Ultimately you may need to set OOM killer values on the things you add, though without the runtime up that may not be an issue in the near term if you don't consume much memory.
Or if what you want to do is have a very locked down and limited UI built on top of the android runtime, you would instead develop a custom home screen , test this on an unmodified emulator, and then deploy it on a build customized to lack any means of installing other applications.
I use IntelliJ IDEA to write Android apps, and use the DDMS Windows application to view the Android logs (separate from the IDE). It works fine, but after a seemingly random period of time, the logs vanish, except for one line of log, which gets overwritten with incoming logs. I have to shut it down and restart it, which combined with the delays of deploying an app to a device over ADB to debug and test is pretty tiresome.
Is this a known issue with DDMS? Is there anything I can do to make it work consistently without breaking itself?
Are there any other Android log viewing applications for Windows that work better? I'm not very fond of the IntelliJ IDEA one. My favourite is actually CatLog on Android itself, but on a small-screen device it's not a great experience.
It's not about the time, but number of lines being recorded. As Dave C said in the comment, just clear the log and it will be fine
Have you tried looking at "Why doesn't LogCat show anything in my Android?"? The top voted answer may solve your problem
Where do I copy the apk file on the Motorola Droid? Which directory? Are there any possible issues I need to be careful of, it's also my personal phone...
To install an apk file, you need to execute
adb install /path/to/file.apk
While the droid is connected. I would avoid using any programs other an adb to install your application. adb will definitely follow the rules and you should be able to clean things up, etc if something goes wrong. That may not be the case with other programs.
I should note, this is assuming you are writing the program yourself. adb is a program that comes with the Android development kit (I assumed you are using this as this is a programming related site. If you are not referring to this and you are simply trying to install a program on your phone, this question would probably be better on superuser.com)
Edit To address your comment. When you select "run" from eclipse, and you have your droid plugged in, it should give you the option to select which device you want to execute the code on. Double clicking on your droid will automatically install and launch the app. You may need to enable the development settings within the Settings menu though for it to be recognized. To confirm that eclipse (really it's adb) can see your droid, launch a terminal or command prompt and type adb devices while the droid is connected. If it's listed there, you're good to go.
I guess I was making it way more complicated than it needed to be. If you have eclipse with the Android plug-in, all you need to do is go into the settings of the phone, then applications, then development. Set the Debug mode to on. when you compile the app with eclipse I guess it looks for an actual phone first, if it detects it, then it loads the app on it. If no phone is detected and you have the ADV set up right it loads it there. Easy... There is a setting about unsigned apps in the application menu, I set it to accept and turned it off after, my apps are still on the phone and work... I am not sure if it was needed at all.
I don't know whether this is how you're supposed to do it, but get Astro File Manager, and you can install your app wherever you place it.
There shouldn't be anything you need to be careful of if it isn't rooted. Programs are pretty well contained and can't do much outside of their own little Dalvik machine.