Home | History | Annotate | Download | only in faq
      1 page.title=Troubleshooting
      2 parent.title=FAQs, Tips, and How-to
      3 parent.link=index.html
      4 @jd:body
      5 
      6 
      7 <p>Here are some tips and tricks for common Android errors. Don't forget to use the
      8     ddms logcat capability to get a deeper view when errors occur. 
      9     See the <a href="{@docRoot}guide/developing/debugging/index.html">Debugging</a> documentation for more information.</p>
     10 <ul>
     11     <li><a href="#installeclipsecomponents">ADT Installation Error: "requires plug-in org.eclipse.wst.sse.ui".</a></li>
     12     <li><a href="#nodevice">ADB reports &quot;no device&quot; when an emulator is running</a></li>
     13     <li><a href="#noapp">My new application/activity isn't showing up in the device application
     14         list </a></li>
     15     <li><a href="#noupdate">I updated my app, but the updates don't seem to be showing up on
     16     the device</a></li>
     17     <li><a href="#layout_wilih">I'm getting a &quot;Binary XML file line #2: You must supply a layout_wilih
     18     attribute&quot; error when I start an application</a></li>
     19     <li><a href="#permission">My request to (<em>make a call, catch an incoming SMS, receive
     20         a notification, send an intent to an Android application</em>) is being
     21         ignored</a></li>
     22     <li><a href="#build">Help! My project won't build in Eclipse</a></li>
     23     <li><a href="#eclipse">Eclipse isn't talking to the emulator</a></li>
     24     <li><a href="#majorminor">When I go to preferences in Eclipse and select "Android", I get the following error message: Unsupported major.minor version 49.0.</a></li>
     25     <li><a href="#apidemosreinstall">I can't install ApiDemos apps in my IDE because of a signing error</a></li>
     26     <li><a href="#gesturebuilderinstall">I can't install the GestureBuilder sample
     27 app in the emulator</a></li>
     28     <li><a href="#signingcalendar">I can't compile my app because the build tools generated an expired debug certificate</a></li>
     29     <li><a href="#manifestfiles">Unable to view manifest files from within Eclipse</a></li>
     30 </ul>
     31 
     32 <a name="installeclipsecomponents" id="installeclipsecomponents"></a><h2>ADT Installation Error: "requires plug-in org.eclipse.wst.sse.ui".</h2>
     33 <p>
     34 The "Android Editors" feature of the ADT Plugin requires specific Eclipse components, such as WST. If you
     35 encounter this error message during ADT installation, you need to install the
     36 required Eclipse components and then try the ADT installation again. Follow the steps below to install the required components for the 
     37 Android Editors feature, based on the version of Eclipse that you are using.</p>
     38 
     39 <table style="font-size:100%">
     40 <tr><th>Eclipse 3.3 (Europa)</th><th>Eclipse 3.4 (Ganymede)</th></tr>
     41 <tr>
     42 <td width="50%">
     43 <ol>
     44 <li>From the dialog where you select the <strong>Update sites to visit</strong>, select the checkboxes for both the
     45 ADT site, and the Callisto/Europa/Ganymede Discovery Site (you may want to
     46 check <strong>Automatically select mirrors</strong> at the bottom).</li>
     47 <li>Click <strong>Finish</strong>.</li>
     48 <li>In the <strong>Next</strong> dialog, select the Android Plugins.</li>
     49 <li>Now, expand the tree item of the discovery site. It seems that if you
     50 don't do it, it doesn't load the content of the discovery site.</li>
     51 <li>On the right, click <strong>Select required</strong>. This will select all the components
     52 that are required to install the Android plugin (wst, emf, etc...).</li>
     53 <li>Click <strong>Next</strong>, accept the agreement, click <strong>Install All</strong>, and restart Eclipse.</li>
     54 </ol>
     55 </td>
     56 <td>
     57 <ol>
     58     <li>Select <strong>Help</strong> &gt; <strong>Software Updates...</strong></li>
     59     <li>Select the <strong>Installed Software</strong> tab.</li>
     60     <li>Click <strong>Update...</strong></li>
     61     <li>If an update for ADT is available, select it and click <strong>Finish</strong>.</li>
     62 </ol>
     63 </td>
     64 </tr>
     65 </table>
     66 
     67 
     68 </p>
     69 <a name="nodevice"></a><h2>ADB reports &quot;no device&quot; when an emulator is running</h2>
     70     <p>Try restarting adb by stopping it (<code>adb
     71         kill-server</code>) then any other adb command to restart it.</p>
     72 
     73 <a name="noapp"></a><h2>My new application/activity isn't showing up in the
     74         applications list </h2>
     75 <ul>
     76     <li>You often must restart your device or emulator before a new activity shows
     77         up in the applications list. This is particularly true when it is a completely
     78         new application with a new AndroidManifest.xml file.</li>
     79     <li>If this is for a new activity in an existing AndroidManifest.xml file, did
     80         you include an <code>&lt;activity&gt;</code> tag for your app (or a <code>&lt;service&gt;</code>        tag
     81         for a service, or a <code>&lt;receiver&gt;</code> tag for a receiver, etc.)? </li>
     82     <li>Make sure that your AndroidManifest.xml file is valid. Errors in attribute
     83         values, such as the <em>value </em> attribute in <code>&lt;action <em>value</em>=&quot;<em>&lt;something&gt;</em>&quot;&gt;</code>
     84         will often not be caught by compilers, but will prevent your application
     85         from being displayed because the intent filter will not be matched. Extra
     86         spaces or other characters can often sneak into these strings.</li>
     87     <li>Did you send your .apk file to the device (<a href="{@docRoot}guide/developing/tools/adb.html#move">adb install</a>)?</li>
     88     <li>Run logcat on your device (<code>adb logcat</code>)
     89         and then install your .apk file. Check the logcat output to see whether the
     90         application is being installed and recognized properly. Here's sample output
     91         from a successful installation:
     92 <pre>I/FileObserver( 414): *** onEvent wfd: 3 mask: 8 path: MyRSSReader.apk
     93 D/PackageManager( 414): Scanning package: /data/app/MyRSSReader.apk
     94 D/PackageManager( 414): Adding package com.example.codelab.rssexample
     95 D/PackageManager( 414): Registered content provider: my_rss_item, className = com.example.codelab.rssexample.RssContentProvider, isSyncable = false
     96 D/PackageManager( 414): Providers: com.example.codelab.rssexample.RssContentProvider
     97 D/PackageManager( 414): Activities: com.example.codelab.rssexample.MyRssReader com.example.codelab.rssexample.MyRssReader2 </pre>
     98     </li>
     99 	<li>If logcat shows that the package manager is having problems loading the manifest
    100 	    file, force your manifest to be recompiled by adding a space in the file and
    101 	    compiling it.</li>
    102 </ul>
    103 <a name="noupdate"></a><h2>I updated my app, but the updates don't seem to be showing up on the device</h2>
    104     <p>Did you remember to send your .apk file to the device (<a href="{@docRoot}guide/developing/tools/adb.html#move">adb
    105         install</a>)?</p>
    106 
    107 <a name="layout_wilih"></a><h2>I'm getting a &quot;Binary XML file line #2: You must supply a layout_wilih
    108     attribute&quot; error
    109     when I start an application (but I declare a layout_wilih attribute <em>right
    110         there!!!</em>)</h2>
    111 <ul>
    112     <li>Make sure that the SDK you are building with is the same version as the Android
    113         OS that you are running on. </li>
    114     <li>Make sure that you're calling setContentView() early in your onCreate() method.
    115         Calling other methods, such as setListAdapter() before calling setContentView()
    116         can sometimes create odd errors when Android tries to access screen elements
    117         that haven't been set before.</li>
    118 </ul>
    119 <a name="permission"></a><h2>My request to (<em>make a call, catch an incoming SMS,
    120 receive a notification, send an intent to an Android application</em>) is being
    121 ignored</h2>
    122     <p>You might not have permission (or might not have requested permission) to
    123         call this activity or receive this intent. Many standard Android activities,
    124         such as making a call, have a permission assigned to it to prevent arbitrary
    125         applications from sending or receiving requests. See <a
    126         href="{@docRoot}guide/topics/security/security.html">Security and
    127         Permissions</a> for more information on permissions, and 
    128 		{@link android.Manifest.permission Manifest.permission} for a list of
    129         standard permissions supported by the Android platform.
    130 </p>
    131 <a name="build"></a><h2>Help! My project won't build in Eclipse</h2>
    132 <p>If your project doesn't build, you may notice symptoms such as new
    133 resources added in the <code>res/</code> sub-folders not showing up in the R class,
    134 the emulator not being started, not being able to run the application, or even seeming to run an old version of the application.</p>
    135 <p>To troubleshoot these types of problems, first try:</p>
    136 <ol>
    137   <li>Switch to the DDMS view in Eclipse (if you don't already have it open):
    138     <ol type="a">
    139       <li>From the menu select <code>Window &gt; Open Perspective &gt; Other</code></li>      
    140       <li>Select DDMS from the list and hit OK</li>
    141     </ol>
    142   </li>
    143   <li>In the Devices panel (top right panel by default), click on the down triangle
    144   to bring up the panel menu</li>
    145   <li>Select <code>Reset ADB</code> from the menu, and then try running the
    146   application again</li>
    147 </ol>
    148 <p>If the above still doesn't work, you can try these steps:</p>
    149 <ol>
    150   <li>
    151     Check the console and problems tabs at the bottom of the Eclipse UI
    152   </li>
    153   <li>
    154     If there are problems listed in either place, they should give you a clue
    155     what is wrong
    156   </li>
    157   <li>
    158     If you aren't sure if the problems are fresh or stale, clear the console
    159     with a right click &gt; Clear, then clean the project
    160   </li>
    161   <li>
    162     To clean the project (a good idea with any kind of build error), select
    163     Project &gt; Clean from the eclipse main menu, then select the project you
    164     are working on (or clean all)
    165   </li>
    166 </ol>
    167 <a name="eclipse"></a><h2>Eclipse isn't talking to the emulator</h2>
    168 <p>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
    169 for a debugger to connect, or errors that Eclipse reports about not being able
    170 to find the emulator or shell. By far the most common symptom is that when you press run, the emulator starts (or
    171 is already running), but the application doesn't start.</p>
    172 <p>
    173 You may find any of these steps will fix the problem and with practice you
    174 probably can figure out which one you need to do for your particular issue, but
    175 to start with, the safest option is to run through all of them in order:</p>
    176 <ol>
    177   <li>
    178     Quit the emulator if it is running
    179   </li>
    180   <li>
    181     Check that any emulator processes are killed (sometimes they    can hang, use ps on unix or mac, or task manager in the process view on
    182     windows).
    183   </li>
    184   <li>
    185     Quit Eclipse
    186   </li>
    187   <li>
    188     From the command line, type: 
    189 <pre>adb kill-server </pre>
    190   </li>
    191   <li>
    192     Start Eclipse and try again
    193   </li>
    194 </ol>
    195 
    196 <a name="majorminor"></a><h2>When I go to preferences in Eclipse and select "Android", I get the following error message: Unsupported major.minor version 49.0.</h2>
    197 <p>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.</p>
    198 
    199 <h2 id="apidemosreinstall">I can't install ApiDemos apps in my IDE because of a signing error</a></h2>
    200 
    201 <p>The Android system requires that all applications be signed, as described in 
    202 	<a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a>. The ApiDemos 
    203 applications included with the SDK are preinstalled on the emulator and for that reason have been 
    204 compiled and signed with a private key.</p>
    205 
    206 If you want to modify or run one of the ApiDemos apps from Eclipse/ADT or other IDE, you can do so 
    207 so only after you uninstall the <em>preinstalled</em> version of the app from the emulator. If 
    208 you try to run an ApiDemos apps from your IDE without removing the preinstalled version first, 
    209 you will get errors similar to: </p>
    210 
    211 <pre>[2008-08-13 15:14:15 - ApiDemos] Re-installation failed due to different application signatures.
    212 [2008-08-13 15:14:15 - ApiDemos] You must perform a full uninstall of the application. WARNING: ...This will remove the application data!
    213 [2008-08-13 15:14:15 - ApiDemos] Please execute 'adb uninstall com.android.samples' in a shell.</pre>
    214 
    215 <p>The error occurs because, in this case, you are attempting to install another copy of ApiDemos 
    216 onto the emulator, a copy that is signed with a different certificate (the Android IDE tools will 
    217 have signed the app with a debug certificate, where the existing version was already signed with 
    218 a private certificate). The system does not allow this type of reinstallation.  </p>
    219 
    220 <p>To resolve the issue, you need to fully uninstall the preinstalled and then reinstall it using 
    221 the adb tool. Here's how to do that:</p>
    222 
    223 <ol>
    224   <li>In a terminal, change to the tools directory of the SDK.</li>
    225   <li>If no emulator instance is running, start an emulator using using the command <code>emulator</code>.</li>
    226   <li>Uninstall the preinstalled app using the command <code>adb uninstall com.example.android.apis</code>.</li>
    227   <li>Reinstall the app using the command <code>adb install &lt;path to the ApiDemos.apk&gt;</code>. If you are 
    228   working in Eclipse/ADT, you can just compile and run the app in the normal way. </li>
    229 </ol>
    230 
    231 <p>Note that if multiple emulator instances are running, you need to direct your uninstall/install 
    232 commands to the emulator instance that you are targeting. To do that you can add the 
    233 <code>-s &lt;serialNumber&gt;</code> to the command, for example: </p>
    234 
    235 <pre>adb -s emulator-5556 install</pre>
    236 
    237 <p>For more information about adb, see the <a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a> 
    238 documentation.</p>
    239 
    240 <h2 id="gesturebuilderinstall">I can't install the GestureBuilder sample 
    241 app in the emulator</a></h2>
    242 
    243 <p>This is similar to the ApiDemos problem described above, except that
    244 you cannot fix it by uninstalling GestureBuilder from the emulator. The 
    245 GestureBuilder app cannot be uninstalled because it is currently installed 
    246 within the system files themselves.</p>
    247 
    248 <p><strong>Symptoms</strong></p>
    249 
    250 <ul><li><p>You cannot run GestureBuilder in the emulator:</p>
    251 
    252 <pre>[2009-12-10 14:57:19 - GestureBuilderActivity]Re-installation failed due to different application signatures.
    253 [2009-12-10 14:57:19 - GestureBuilderActivity]You must perform a full uninstall of the application. WARNING: This will remove the application data!
    254 [2009-12-10 14:57:19 - GestureBuilderActivity]Please execute 'adb uninstall com.android.gesture.builder' in a shell.</pre>
    255 </li>
    256 
    257 <li><p>Running <code>adb uninstall com.android.gesture.builder</code> fails:</p>
    258 <pre>$ adb uninstall com.android.gesture.builder
    259 	Failure</pre>
    260 </li></ul>
    261 
    262 <p>For now, the work-around is to change the sample's package name
    263 so that the system can install it as a new app rather than as a 
    264 replacement for the existing GestureBuilder app. To change the 
    265 package name, open the manifest file and modify the package attribute 
    266 of the manifest element. Next, update imports and other references to 
    267 the package name, rebuild the app, and run it in an AVD.</p>
    268 
    269 <p>For example, here's how you could do this in Eclipse:</p>
    270 
    271 <ol>
    272   <li>Right-click on the package name
    273 (<code>src/com.android.gesture.builder</code>).</li>
    274   <li>Select <strong>Refactor &gt; Rename</strong> and change the name, for example to
    275 <code>com.android.gestureNEW.builder</code>. </li>
    276   <li>Open the manifest file. Inside the <code>&lt;manifest&gt;</code>
    277 tag, change the package name to
    278 <code>com.android.gestureNEW.builder</code>.</li>
    279   <li>Open each of the two Activity files and do Ctrl-Shift-O to add
    280 missing import packages, then save each file.</li>
    281 <li>Run the GestureBuilder application on the emulator.</li>
    282 </ol>
    283 
    284 <p>If you get an error message such as "Could not load /sdcard/gestures. 
    285 Make sure you have a mounted SD card," be sure that your target AVD has an 
    286 SD card. To create an AVD that has an SD card, specify one when creating
    287 an AVD with the AVD manager. See 
    288 <a href="{@docRoot}guide/developing/devices/managing-avds.html#createavd">
    289 Creating and Managing AVDs with AVD Manager</a> for more information.</p>
    290 
    291 <h2 id="signingcalendar">I can't compile my app because the build tools generated an expired debug certificate</h2>
    292 
    293 <p>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. </p>
    294 
    295 <p>The problem occurs because the Keytool utility &mdash; included in the JDK and used by the Android build tools &mdash; 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.</p>
    296 
    297 <p>If you encounter this problem, follow these steps to work around it: </p>
    298 
    299 <ol>
    300 <li>First, delete the debug keystore/key already generated by the Android build tools. Specifically, delete the <code>debug.keystore</code> file. On Linux/Mac OSX, the file is stored in <code>~/.android</code>. On Windows XP, the file is stored in <code>
    301 C:\Documents and Settings\&lt;user&gt;\.android</code>. On Windows Vista, the file is stored in <code>
    302 C:\Users\&lt;user&gt;\.android</code></li>
    303 <li>Next, you can either
    304 <ul>
    305 <li>Temporarily change your development machine's locale (date and time) to one that uses a Gregorian calendar, for example, United States. Once the locale is changed, use the Android build tools to compile and install your app. The build tools will regenerate a new keystore and debug key with valid dates. Once the new debug key is generated, you can reset your development machine to the original locale. </li>
    306 <li>Alternatively, if you do not want to change your machine's locale settings, you can generate the keystore/key on any machine using the Gregorian calendar, then copy the <code>debug.keystore</code> file from that computer to the proper location on your development machine. </li>
    307 </ul>
    308 </li>
    309 </ol>
    310 
    311 <p>This problem has been verified on Windows and may apply to other platforms. </p>
    312 
    313 <p>For general information about signing Android applications, see 
    314 <a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a>. </p>
    315 
    316 <h2 id="manifestfiles">Unable to view manifest files from within
    317 Eclipse</a></h2>
    318 
    319 <p>When you try to open an application's manifest file from within
    320 Eclipse, you might get an error such as this one:</p>
    321 <pre>An error has occurred. See error log for more details.
    322 org.eclipse.wst.sse.ui.StructuredTextEditor.isBlockSelectionModeEnabled()Z</pre>
    323 
    324 <p>Try reverting to the 3.0 version of the Eclipse XML Editors and
    325 Tools. If this does not work, remove the 3.1 version of the tool. To do
    326 this in Eclipse 3.4:</p>
    327 
    328 <ol>
    329 	<li>Select <strong>Help > Software Updates...</strong></li>
    330 	<li>Select the <strong>Installed Software</strong> tab.</li>
    331 	<li>Select <strong>Eclipse XML Editors and Tools</strong>.</li>
    332 	<li>Click <strong>Uninstall</strong>.</li>
    333 	<li>Click <strong>Finish</strong>.</li>
    334 </ol>
    335 
    336 <p>When you restart Eclipse, you should be able to view the manifest
    337 files. </p>