The app works fine in the emulator, but after installation on a phone, it crashes every time on launch, and logcat shows no errors.
What am I supposed to do when something like this happens?
My Suggestion for easier resolution of your problem :
Run the app from the eclipse in debug mode on the Phone . It will make it run on debug mode. You will most likely get more debug output.
Turn on ADB in the phone.
Connect the Phone to the PC
Run as "Debug Configuration" from eclipse.
It should run from your phone and Eclipse will ask for your choice for first time before running that.
Turning the Debug Mode on ( Note : This isn't the 'ADB connection' we are referring to ) , It will enable further logging of the application and doesn't do garbage collection normally.
( You will notice a 'Waiting for debug connection' dialogue , if the applications are forced to work in debug mode ).
For e.g :It makes the Async threads keep running and doesn't stop running. Crude and irrelevant for your case . But just as an example.
So , Since the Applications in the phone are forced to run in debug mode , it will get the logcat with detailed errors down to the specific threads.
However, the debug mode is better used when it's used in conjunction with "Debug As" run configuration from Eclipse. And keep in mind that it will automatically turn on that debug application mode ( And there by the dialog box also) , the logcat will show you more details and plus it will break-point at the errors which occur ,in their sequence of occurence.
Regarding what Ares told,
When you want to do the debugging of a process directly,
You can go to the DDMS panel in Eclipse,
On the right side tab menu Devices ,
Select the process you want to debug . and click on the green symbol ( Says, Start Debugging process )
It will automatically go to the source when it breaks if you have the source code in that eclipse work-space.
Additional hint:
On huawei phones, logcat doesn't show debug messages and excpetions, if the phone is in default system settings.
In order to enable logcat full logs on Huawei phones, you must do the following:
Open the factory settings menu by dialing *#*#2846579#*#*
Navigate to Project Menu / Background Setting / Log setting
On older phones: define the log availability (log switch) and level (log level setting).
On never phones: tick AP Log (which seems to enable app logging in general) and CP Log (seems to enable debug logging)
Close the menu with your backbutton (no restart needed)
Source: https://stackoverflow.com/a/18395092/1075072
Install a tool like AndroidSystemInfo that can show you the logfile on the phone - even when you are away from the host computer.
It is pretty unusual that Android leaves no trace whatsoever.
Does your app perhaps require features that the phone does not have (e.g. a camera or gps or nfc)?
In Eclipse you should go to DDMS, then click on device's name or android.os in Devices panel. And turn your device in debug mode.
Put your own logs to track what block of code cause crashe, or just debug it.
You can reset adb (In Devices -> View menu -> Reset adb)
Click on the selected online device/emulator to show the logcat
Disconnect the cable and again connect it. (Or restart the emulator)
Restart Eclipse
I restarted my emulator and cleaned my build. This got rid of both the non-logging and the spurious crash I was having
Related
In the Android app I'm currently working on I have all my try/catches to print out a stack trace but when using a physical android device via USB these errors do not seem to get printed. Further more, when I attempt to create a debug log on the device, it never shows up. My assumption is that I have to start relying on Log.d and print everything to the logcat. Is this correct?
Edit: I should also mention that these stack traces appear when using an emulator as well.
Also, I have noticed when debugging on a physical device when I hit break points it locks the application but it does not allow me to continue with debugging, a.k.a pass over the break point. Is this an error or simply how it preforms? Break points work fine on the genymotion emulator.
You are doing something in wrong way, be sure not to debug and look for logs at the same time and be sure you are using right filter at loging.
And at last be sure that you turn on debug mode on at your release version of app(or what version you are using at device).
For the logs, you should have to check is the log is enable, by using the following steps in eclipse:
* Go in Windows -> Preferences.
* After that, select Android -> LogCat.
* And set the option "Show logcat view if message priority is atleast:" to "VERBOSE".
OK, logcat is showing system logs but it is not showing application log on my Huawei Ascend. If I switch to another device such as my Galaxy Nexus or Nexus 7 then for the same app (same APK even) log is displayed.
The Huawei Ascend is running Android 4.1.1, it has USB debugging switched on in developer options. This occurs for logcat run from either the command line or from IntelliJ. And I'm making sure that the correct device is selected - in fact I'm only plugging a single device in at a time. I've tried restarting adb, clearing it's buffer etc
I can see that the app is starting on the Huawei, I even get system logs showing that the Activity has started. But unlike on the other devices I get no app log in the Activity#onCreate (or from anywhere else).
08-08 20:55:44.050: INFO/WindowManager(431): Switching to real app window: Window{41ae8780 au.com.xandar.wirelesstiming.timekeeper/au.com.xandar.wirelesstiming.timekeeper.TimeKeeperActivity paused=false}
08-08 20:55:44.180: INFO/ActivityManager(431): Displayed au.com.xandar.wirelesstiming.timekeeper/.TimeKeeperActivity: +387ms
How can the application log not be getting delivered?
OK, since I had another Huawei Ascend I ran into the same problem. This time I have the exact answer. Follow these instructions (from denispyr's answer on Why doesn't logcat show anything in my Android?)
Dial
*#*#2846579#*#*
and you will see a hidden menu. Go to the Project Menu > Background Setting > Log setting and define the log availability (log switch) and level (log level setting).
And then make sure you restart your phone.
Please note this probably only applies to Huawei phones.
Also note that if you're on a Huawei tablet (e.g. MediaPad M3), instead of dialing, you launch the Huawei Calculator in landscape and enter ()()2846579()().
For Huawei with Android 8.0+
we must dial the code: *#*#2846579#*#*
and selecting the option AP Log will be enough to display the messages in the LogCat.
If any one having Letv Phone (LeEco Le Max 2 or 1) above solution won't work. Try the below USSD. Fig.1 for reference.
Press Dialer *#*#76937#*#*
Select "Enable All Logs"
Instead of using
Log.d(TAG, msg);
Try this.
Log.wtf(TAG, msg);
work for me.
I have a HUAWEI Y3 II aka LUA-L21.
The accepted answer didn't work for me.
It led to some MTKLogger settings screen, which is different than described in the answer, and didn't help at all.
My solution
Dial *#*#2846580#*#* (please note this code is different from the one in the accepted answer)
You just entered a settings screen called EngineerMode (again, different from accepted answer's ProjectMenu)
In the first Telephony tab, click the Log Control item
Activate both switches (set Mtklog control to catch all log and adb radio log to catch radio log by adb)
Back in the previous screen, swipe to the Log and Debugging tab
Open Debug Utils
Change Debug Level from User Mode to Engineer Mode
For good measure, restart your phone
Screens
Changing Log control
Changing Debug utils
Additional notes
Just to clarify my original problem; logcat was showing some of my app's log entries, just not my own messages - I saw entries belonging to my process com.example.myapp, but never anything I was printing out myself, in my code, using Log.d("TAG", "hello world");
There was plenty of stuff like this:
4260-4270/com.example.myapp I/art: Debugger is no longer active
4260-4412/com.example.myapp I/System.out: [CDS]rx timeout:1
4260-4412/com.example.myapp D/NativeCrypto: doing handshake ++
4260-4603/com.example.myapp D/OpenGLRenderer: Flushing caches (mode 0)
4260-4603/com.example.myapp D/Surface: Surface::disconnect(this=0xb85285d8,api=1)
4260-4260/com.example.myapp D/ActivityThread: ACT-STOP_ACTIVITY_HIDE handled : 0 / android.os.BinderProxy#2333cbdf
...but never anything like this:
4260-4603/com.example.myapp D/MainActivity: hello from onCreate!
The above steps solved the issue for me.
Some newer versions of Huawei Phones (I am using a Y9s 2019) have some settings changed.
Process is now
Dial *#*#2846579#*#*
Background Settings -> AP LOG Settings -> Open.
If you still can't see the logs, restart both your phone and Android Studio/Eclipse
Open your Dialer app and enter the following code: *#*#2846579#*#*.
1-Enter the Background Settings page.
2-Click on “Log Settings”
3-Check all 3 options to enable full logging.
4-Ignore the "will affect performance" warning.
5-Reboot the phone.
Try downloading a Logcat app(eg aLogCat) on your device itself and see if you are having the same problem.
I know its not a complete solution, but this way you may be able to figure out whats going wrong by reading the application logs.
Try this:
In Eclipse editor:
Reset adb from windows-->devices and then try again ...
please check your project is highlighted with green color (simply select your projrct name)
Sometime just after I launched a new emulator, for very first time I was trying to upload my apk, however I got "emulator: ERROR: the user data image is used by another emulator. aborting".
I launched a new emulator, and left it alone, several minutes later, DDMS showed "device offline".
I had to restart a new one, you know, minutes wasted.
It's really bothering that I keep getting this error and slowed down debugging.
How do I fix it?
If the emulator is still alive, you can tell adb to connect to it via tcp (which is I believe what it does anyway, only it normally uses an 'emulator' class of name and would now get a ip:port one)
It's been a while since I've had to do that, but I think that if you were using emulator-5554 you would connect to your development machine's loopback one port higher, ie:
adb connect localhost:5555
If it works adb devices will show it an eclipse should see it as a deployment option
The 'in use' problem sounds like a stale lockfile perhaps left behind in a crash
I have another solution. try this
Run configurations > Target > Wipe user data > Run
In my case it happens when I have another process listening on emulator port.
e.g. if I see:
emulator-5554 offline
it means that something is using port 5554
Manually delete these following folders:
C:\Users\%UserName%.android\avd\AVD2.1.avd\cache.img.lock
C:\Users\%UserName%.android\avd\AVD2.1.avd\userdata-qemu.img.lock
this always works for me. :3
On Arch Linux x64, I had this similar problem which led me to this question. Using Eclipse, the emulator-5554 window would freeze, and Eclipse prompted me to start a new one. In the following dialog, emulator-5554 was reported to be offline, with an unknown target. If I started a new instance, it would be emulator-5556. This problem persisted through Eclipse restarts and log-off-on cycles too! Further, killx would close the window, but the process was still running.
So, find the emulator64-arm process id (not emulator-arm!):
ps ax | grep "emulator64-arm"
...and then just kill -9 it:
sudo kill -9 6728
...where 6728 was its PID. This completely disconnects the emulator so Eclipse can try to run it again.
Open android debug monitor window by
typing "monitor" command in cmd,
then select device in the monitor window,
click on down arrow as shown in the figure then just click on reset tab thats all you will get internet connection.
It was some strange
I had that problem, automatically stopped the emulator localhost:5554 after to launch the application.
I didn't know why it happens but intil today I did something different at I could launch as normality.
What I did as different was to change the prespective of Eclipse ADT. I was executing the application from Debug and now I executed from Java Prespective, it worked, I don't know the reason, I had to share it, sound some .. this answer but I resolved doing that without deleting and creating again my android virtual device.
Sometimes we see the device restarts automatically, while few other times I had found it switching off after long time, even battery was not low.
So if we want to trace back of what actually has caused this, does we have any log file in device memory which has the cause of shutdown or restart ?
Like we get the dump for the other O.S. for any errors occured causing it to restart/shutdown in specific error log file. Similarly does android has such ?
It may be anywhere , even in internal memory, so with root privileges I can go into looking for it.
Any thoughts ? Thanks.
If you have installed Terminal on your phone just tupe in
su
logcat
If not enable DebbugingMode on your phone, connect it with your PC/Mac, open Eclipse and go to Debug.
There it will show the log of the phone.
I hope this helps.
I've just started going through the tutorials but seem to be having some trouble with the following portion:
"Run > Debug History > Hello, Android from the menu to enter debug mode. Your app will restart in the emulator, but this time it will suspend when it reaches the breakpoint you set. You can then step through the code in Eclipse's Debug Perspective, just as you would for any other application."
when I follow these instructions I see a list of warnings like this...
[2010-11-24 15:39:43 - ddms]Can't bind to local 8617 for debugger
and finally this...
[2010-11-24 16:08:25 - HelloAndroidWeb] Launch error: Failed to connect to remote VM. Connection refused.
I've never used a debugger before but from reading the tutorail I expect a new window to open (the Debug Perspective), but this is not the case. Have I dont something wrong in during installation/setup.
Thanks
Is the application running on the emulator or an attached device? If on a device, USB Debugging mode needs to be enable through the setup menu. If in the emulator, you may have to restart it in order to reattach the debugger (ADB).
In the 'Devices' panel do you see the list of active processes running? Can you select your application and click on the 'Debug select process' icon?
Is debbing set to true in your manifest?