Here are some tips and tricks for common Android errors. Don't forget to use the ddms logcat capability to get a deeper view when errors occur. See Debugging for more debugging tips.
The "Android Editors" feature of the ADT Plugin requires specific Eclipse components, such as WST. If you encounter this error message during ADT installation, you need to install the required Eclipse components and then try the ADT installation again. Follow the steps below to install the required components for the Android Editors feature, based on the version of Eclipse that you are using.
Eclipse 3.3 (Europa) | Eclipse 3.4 (Ganymede) |
---|---|
|
|
Try restarting adb by stopping it (adb
kill-server
) then any other adb command to restart it.
<activity>
tag for your app (or a <service>
tag
for a service, or a <receiver>
tag for a receiver, etc.)? <action value="<something>">
will often not be caught by compilers, but will prevent your application
from being displayed because the intent filter will not be matched. Extra
spaces or other characters can often sneak into these strings.adb logcat
)
and then install your .apk file. Check the logcat output to see whether the
application is being installed and recognized properly. Here's sample output
from a successful installation:
I/FileObserver( 414): *** onEvent wfd: 3 mask: 8 path: MyRSSReader.apk D/PackageManager( 414): Scanning package: /data/app/MyRSSReader.apk D/PackageManager( 414): Adding package com.example.codelab.rssexample D/PackageManager( 414): Registered content provider: my_rss_item, className = com.example.codelab.rssexample.RssContentProvider, isSyncable = false D/PackageManager( 414): Providers: com.example.codelab.rssexample.RssContentProvider D/PackageManager( 414): Activities: com.example.codelab.rssexample.MyRssReader com.example.codelab.rssexample.MyRssReader2
Did you remember to send your .apk file to the device (adb install)?
You might not have permission (or might not have requested permission) to
call this activity or receive this intent. Many standard Android activities,
such as making a call, have a permission assigned to it to prevent arbitrary
applications from sending or receiving requests. See Security and
Permissions for more information on permissions, and
Manifest.permission
for a list of
standard permissions supported by the Android platform.
If your project doesn't build, you may notice symptoms such as new
resources added in the res/
sub-folders not showing up in the R class,
the emulator not being started, not being able to run the application, or even seeming to run an old version of the application.
To troubleshoot these types of problems, first try:
Window > Open Perspective > Other
Reset ADB
from the menu, and then try running the
application againIf the above still doesn't work, you can try these steps:
When communication doesn't seem to be happening between Eclipse and the emulator, symptoms can include: nothing happening when you press run, the emulator hanging waiting for a debugger to connect, or errors that Eclipse reports about not being able to find the emulator or shell. By far the most common symptom is that when you press run, the emulator starts (or is already running), but the application doesn't start.
You may find any of these steps will fix the problem and with practice you probably can figure out which one you need to do for your particular issue, but to start with, the safest option is to run through all of them in order:
adb kill-server
This error is displayed if you are using an older version of the JDK. Please make sure you are using JDK version 5 or 6.
The Android system requires that all applications be signed, as described in Signing Your Applications. The ApiDemos applications included with the SDK are preinstalled on the emulator and for that reason have been compiled and signed with a private key.
If you want to modify or run one of the ApiDemos apps from Eclipse/ADT or other IDE, you can do so so only after you uninstall the preinstalled version of the app from the emulator. If you try to run an ApiDemos apps from your IDE without removing the preinstalled version first, you will get errors similar to:[2008-08-13 15:14:15 - ApiDemos] Re-installation failed due to different application signatures. [2008-08-13 15:14:15 - ApiDemos] You must perform a full uninstall of the application. WARNING: ...This will remove the application data! [2008-08-13 15:14:15 - ApiDemos] Please execute 'adb uninstall com.android.samples' in a shell.
The error occurs because, in this case, you are attempting to install another copy of ApiDemos onto the emulator, a copy that is signed with a different certificate (the Android IDE tools will have signed the app with a debug certificate, where the existing version was already signed with a private certificate). The system does not allow this type of reinstallation.
To resolve the issue, you need to fully uninstall the preinstalled and then reinstall it using the adb tool. Here's how to do that:
emulator &
.adb uninstall com.android.samples
.adb install <path to the ApiDemos.apk>
. If you are
working in Eclipse/ADT, you can just compile and run the app in the normal way. Note that if multiple emulator instances are running, you need to direct your uninstall/install
commands to the emulator instance that you are targeting. To do that you can add the
-s <serialNumber>
to the command, for example:
adb -s emulator-5556 install
For more information about adb, see the Android Debug Bridge documentation.
This is similar to the ApiDemos problem described above, except that you cannot fix it by uninstalling GestureBuilder from the emulator. The GestureBuilder app cannot be uninstalled because it is currently installed within the system files themselves.
Symptoms
You cannot run GestureBuilder in the emulator:
[2009-12-10 14:57:19 - GestureBuilderActivity]Re-installation failed due to different application signatures. [2009-12-10 14:57:19 - GestureBuilderActivity]You must perform a full uninstall of the application. WARNING: This will remove the application data! [2009-12-10 14:57:19 - GestureBuilderActivity]Please execute 'adb uninstall com.android.gesture.builder' in a shell.
Running adb uninstall com.android.gesture.builder
fails:
$ adb uninstall com.android.gesture.builder Failure
For now, the work-around is to change the sample's package name so that the system can install it as a new app rather than as a replacement for the existing GestureBuilder app. To change the package name, open the manifest file and modify the package attribute of the manifest element. Next, update imports and other references to the package name, rebuild the app, and run it in an AVD.
For example, here's how you could do this in Eclipse:
src/com.android.gesture.builder
).com.android.gestureNEW.builder
. <manifest>
tag, change the package name to
com.android.gestureNEW.builder
.If you get an error message such as "Could not load /sdcard/gestures.
Make sure you have a mounted SD card," be sure that your target AVD has an
SD card. To create an AVD that has an SD card, use the
-c
option in the android create avd
command.
If your development machine uses a locale that has a non-Gregorian calendar, you may encounter problems when first trying to compile and run your application. Specifically, you may find that the Android build tools won't compile your application because the debug key is expired.
The problem occurs because the Keytool utility — included in the JDK and used by the Android build tools — fails to properly handle non-Gregorian locales and may create validity dates that are in the past. That is, it may generate a debug key that is already expired, which results in the compile error.
If you encounter this problem, follow these steps to work around it:
debug.keystore
file. On Linux/Mac OSX, the file is stored in ~/.android
. On Windows XP, the file is stored in
C:\Documents and Settings\<user>\.android
. On Windows Vista, the file is stored in
C:\Users\<user>\.android
debug.keystore
file from that computer to the proper location on your development machine. This problem has been verified on Windows and may apply to other platforms.
For general information about signing Android applications, see Signing Your Applications.
When you try to open an application's manifest file from within Eclipse, you might get an error such as this one:
An error has occurred. See error log for more details. org.eclipse.wst.sse.ui.StructuredTextEditor.isBlockSelectionModeEnabled()Z
Try reverting to the 3.0 version of the Eclipse XML Editors and Tools. If this does not work, remove the 3.1 version of the tool. To do this in Eclipse 3.4:
When you restart Eclipse, you should be able to view the manifest files.