I'm new to Java and more than I'm new to Android. After reading and trying some tutorials I was thinking to make an mp3 player application, but I'm stuck already. I assume that my runtime error is in the following method and more specifically the if condition.
public void pausePlay(){
if(player.isPlaying()){
demoPause();
} else {
demoPlay();
}
}
Maybe I'll be able to solve my problem, but my debugger doesn't work. Or I don't know how to use the debugger. The following links are a printscreen of my debugger, DDMS and LogCat. Also on github I posted my repository.
In eclipse try the following steps to debug your code:
1.Put a break point in your code where you think the problem is(the app will pause in device when it reaches that code later you can continue to look code flow by pressing F6)
2.Click ddms->device-> If the device is attached it will show you the list of processes, select your process and click green debug icon at top of device.
3.Run your app, when the code flow reaches break point app will pause a dialog appears in eclipse click yes to continue. Next you can continue debugging in eclipse.
Related
When trying to set up hand tracking following the hand tracking-documentation unity just shuts down when pressing play without any crashlog/warning. Here are the steps that I have done up until the crash to reproduce my problem:
Creating completely new scene.
Importing the Oculus Integration from asset store.
Switching platform to Android.
Add OVRCameraRig to hierachy.
Change OVRCameraRig's Hand tracking support to "Controllers & Hands" on OVR Manager-script.
Up to step 5 I can press play whenever and it starts as usual. But when doing the next step it crashes everytime.
Add "OVRHandPrefab" to OVRCameraRig > TrackingSpace > LeftHandAnchor/RightHandAnchor.
Has anyone experienced a similar problem to this?
Thanks in advance!
EDIT: Unity does not crash when removing Link cable from laptop. So has certainly something to do with link.
Have you tried enabling hand tracking in your Quest Headset (while unplugged)?
Its in Settings -> Experiments -> Enable Hand Tracking
I also have 'Auto detect hands or controllers' enabled. To see your hands, the new OVRCustomHandPrefab does the trick.
[Edit]
Also the headset seems to cause crashes after its been sitting on the desk connected to Link for more than a few minutes. Unplugging and reconnecting will refresh it.
I don't know if you were able to solve this issue or not, but for any other person who is facing a similar issue, here is how I solved it:
When you add OVRHandPrefab to LeftHandAnchor and RightHandAnchor, set the gameobject to false in the inspector.
Then in your script, check if handtracking is enabled by running this code in Update() OVRPlugin.GetHandTrackingEnabled()
Set both the OVRHandPrefab to true only when OVRPlugin.GetHandTrackingEnabled() returns true, something like this:
if (OVRPlugin.GetHandTrackingEnabled())
{
ovrHandPrefabLeft.SetActive(true);
ovrHandPrefabRight.SetActive(true);
}
else
{
ovrHandPrefabLeft.SetActive(false);
ovrHandPrefabRight.SetActive(false);
}
This should avoid Unity from crashing.
I'm debugging my Android app using Eclipse. The app runs in Android Emulator, not on a real phone. After a breakpoint is hit, only Resume (F8) and Run to Line (Ctrl+R) are enabled, while Step Into (F5) and Step Over (F6) are disabled:
The breakpoint is set to "Suspend VM", if that has any relevance:
Why are they disabled, and is there any way to enabled them?
Edit: I tried placing a second breakpoint on the next line, then hit Resume, and when that second breakpoint was hit, "Step Into (F5)" and "Step Over (F6)" were no longer disabled. I don't know if this will work every time though.
In order for the control button to activate you just need to choose the thread that your code is running on from the Debug window.
In Debug perspective, choose the thread that is marked Suspended from the Debug window.
Usually step into works for a method or a constructor initalization or aything like that. We can also step into inbuilt methods in Android Studio now as the class gets decompiled. maybe that particular line was an assignment statement or something that cannot be stepped into.
I'm trying to debug an application that I'm writing using Android Studio but I can't seem to get any useful debugging information out of Android Studio's "Debug" view. I'm launching my application with the bug-looking "Debug" icon but the "Debug" view doesn't have anything useful (no stack frames from my application, for example):
Even if my application crashes I don't get any useful information. As I recall, the ADT plugin would automatically drop you on the line that caused the crash.
Do I need to do anything else to make my application "debuggable" in Android Studio? I've also tried forcing android:debuggable="true" in my AndroidManifest.xml but to no avail. Android Studio does seem to be attaching to the running process (the app shows the "attaching to debugger" message for a few seconds when it first launches).
There are some things to check:
If your app-debugger is working and stopping on normal breakpoints, maybe you have to set an exception-breakpoint:
Open Debugger
Press "View breakpoints"
Usually, there should be a breakpoint called "Any exception" with checkboxes on "Caught exception" and "Unchaught exception". If not, add an exception breakpoint yourself and specify the type(s) of exceptions you want the debugger to stop on (you can use wildcards in the exception-classnames, e.g. *Exception).
If your app-debugger is not working, check the following options:
Check if you have enabled USB-Debugging in the developer options of your device
Check if you have authorized the computer as a development machine in the developer options of the device (if unsure, clear the authorization-list from the developer options page and reconnect the device)
Check if your development machine has only one adb-server-process running in the background (if more, kill all of them with a process mananger and restart with "adb start-server")
Add "debuggable true" to your debug-buildType in build.gradle:
buildTypes {
debug {
debuggable true
}
...
}
If your app-debugger is still not working, restart your computer and re-install adb-drivers for your device. Make sure there are no conflicting drivers active with more than one connected device (maybe connecting only one at a time).
Note: even if you got exception breakpoints working, they might not be useful at all, depending on the type of the crash. Most of the times, you will get the debugger stopping in the Zygote-exception handler where you don't get much useful information or stacktrace.
In such cases, it is the easiest to just let the debugger resume or reproduce the crash without a debugger, and check the logcat-output for a stacktrace in the ERROR-loglevel of your app's logcat-output. Those stacktraces should have clickable line-infos thus enabling you to set a normal breakpoint on a relevant line of code in your app's source code to analyze the problem.
After updating Android studio this problem went away. Not sure what the issue was.
My LogCat is often not showing null pointer exceptions..
Sample:
ProgressDialog pd;
ps.show();
Application stops (do not reacts for any action), but there is no information about any reason in logcat.
Another sample is with database - if there is no DB and I'm making actions on it, the same happens.
I tried (that action with DB) on my colleague's phone and there was normal error. I have all needed programmer options in my phone turned on.
Maybe someone know , why it is so? It was not burdensome, when I had small app, but now when it's bigger, it can be really frustrating.
I get this with android studio too...
Close android studio, restart ADB, and generally it starts working for me.
If that does not work then put a breakpoint at the line .show(); ... Then open up the logcat and then skip over the breakpoint. It then shows, I have similar issues.
(Windows 7 64 bit - Android Studio 0.82)
I dont like the IDE logcat option honestly.
The SDK comes with an adb binary, use the logcat option from there via
adb logcat or my personal favorite built in alias, adb lolcat
This will give you the log information for EVERYTHING happening on the device, and can be useful tracking down issues caused by device state.
For example, you can see network changes in the logcat, and if your app crashes on network call you wouldnt have any idea why if you just used the logcat output from your app.
In my case I was using: Thread.setDefaultUncaughtExceptionHandler in my application file. If that is not turned off during debugging you won't see any exception output. ( Just make sure to turn it back on again when you release so you can still handle your issues ).
All of a sudden I am not able to debug anything that i am doing in a service even though i put breakpoints all over. but logging shows that all the lines are getting executed. Can someone tell me what could be causing this issue. I am using eclipse and i have set to "Build automatically".
Do you have an Activity which is launched at the beginning of your application?
If not you have to manually activate the debug on your process by using the DDMS tool in Eclipse.
In DDMS -> Devices, check your process (the line contains the package name of your app), select it and then click on the debug button. A debug icon will appear near your process, then you should be able to use breakpoints in your Service.
If you are using a Runnable try placing this in the run() method:
android.os.Debug.waitForDebugger();