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