-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Troubleshooting Common Issues
If you are having trouble with Android, Eclipse, or the Emulator, check here for common problems and solutions for Android development problems. A few of the most common ones encountered are listed below.
You should be able to use Autocompletion (Ctrl + Space) to complete words as you code. If you can't, try the following steps:
- Try restarting eclipse, quit and re-open. Check to see if autocompletion has returned.
- Open eclipse and go to the following in the menu:
Preferences > Java > Editor > Content Assist > Advanced
. Select all checkboxes here (especially ones mentioning Java) and click OK. - Open eclipse and go to the following in the menu:
Preferences > General > Keys
and the find the Command "Content Assist" in the list and remap the "Binding" to a different set of keys and click OK.
See a red line under a class that should exist (i.e ArrayList, View)? - Hover over the class and select "import" from the list of suggestions or better use "Cmd + Shift + O" to auto-import all missing types.
This means that the project does not have an R
file generated and is usually a sign of a bad state. Try a seres of steps to fix:
- Try running
Project => Clean
to regenerate the file - Look for errors in "Console" or "Problems" to resolve
- Try relaunching Eclipse
Getting this error means your Android installation is likely corrupted in some way. Typically this error will occur on projects in particular cases such as generating a new icon or adding a new xml file. If you see this error in your "Problems" window after a clean, try closing and reopening Eclipse first, then try doing a Project => Clean
.
If the same message persists, you may need to do a complete reinstallation of the ADT Bundle which includes eclipse. You should delete the entire existing ADT bundle from your computer (including eclipse and SDK folder) and re-download the bundle, extract the contents and re-setup from scratch. Users rarely experience this error after a total reinstall.
- Switch to DDMS mode in Eclipse
- Verify the emulator is listed and select the emulator
- Select the small down arrow and click "reset adb"
- Still having problems? Time to restart eclipse
- Open "Window => Android Virtual Device Manager"
- Click "Edit" on your Virtual Device and verify "Intel x86" is selected for CPU
- Make sure not to close your emulator once it is booted, leave it open and just re-run
- Go to Intel HAXM page and install the latest hotfixes for your platform.
- Open "Window => Android Virtual Device Manager"
- Click "Edit" on your Virtual Device and toggle the "Use Host GPU" checkbox
- Verify the CPU has "Intel x86" selected rather than "ARM"
- Now fully restart the emulator and relaunch
Check out this post for quick fix.In short, we have to edit a file specifying the X/Y coordinates for the virtual device to use to position itself on startup. If these coordinates are outside the normal bounds of the primary monitor, then the emulator will crash.
- Edit the file
~/.android/avd/.avd/emulator-user.ini
- Reset the value of both
window.x
andwindow.y
to 0
- This means your application had a runtime crash
- If you don't see LogCat, open with
Window => Show View => Other => Android => LogCat
- Use LogCat to debug where the crash originated (or use the debugger)
- Find the error stacktrace and identify the line (in your code) that triggered the error.
- This is often a NullPointerException (accessing a null object) or other null references (such as an
android:onClick
handler referencing a non-existent method)
Created by CodePath with much help from the community. Contributed content licensed under cc-wiki with attribution required. You are free to remix and reuse, as long as you attribute and use a similar license.
Finding these guides helpful?
We need help from the broader community to improve these guides, add new topics and keep the topics up-to-date. See our contribution guidelines here and our topic issues list for great ways to help out.
Check these same guides through our standalone viewer for a better browsing experience and an improved search. Follow us on twitter @codepath for access to more useful Android development resources.