Android-Common Bugs and solutions, androidbugs

Source: Internet
Author: User

Android-Common Bugs and solutions, androidbugs

Reprinted please indicate the source: http://blog.csdn.net/l1028386804/article/details/46942139

1. android. view. WindowManager $ BadTokenException: Unable to add window -- token null is not for an application
Solution: Change getApplication to xxxx. this.
2. call you are unregister onbrocastRevicer?
Solution: forget to cancel Broadcast
3. Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE indicates that an application has not been uninstalled.
4. launch Activtiy not found? Because this Activity does not write the main and luncher Parameters
5. R. java was removed! Recreating R. java!
6.com. process. acore indicates that this application has a dialing process.
7. android. database. CursorIndexOutOfBoundsException solution: the reason is that you should first call cursor. moveToFirst ();.
The database has only one result in the obtained cursor, but you cannot find the first result.
8.launcher.apk the Startup Program is stuck on the boot animation page because the cpu is temporarily used for the boot animation. If some code in luancher is blocked, or some codes in a custom view occupy too much CPU.
9. java. lang. IllegalStateException: The specified child al
Ready has a parent. You must call removeView () on the child's parent first, indicating that the object is missing,
Solution: Find whether the object is still there, or use multiple examples.

10. java. lang. illegalStateException: The content of the adapter has changed but ListView did not receive a notification. make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView (2131230732, class android. widget. listView) with Adapter (class com. cardroid. sdhc. medialist. SDMediaListAdapter)]
01-01 00:51:06. 320: ERROR/AndroidRuntime (4035): at android. widget. ListView. layoutChildren (ListView. java: 1492)
01-01 00:51:06. 320: ERROR/AndroidRuntime (4035): at android. widget. AbsListView. onTouchEvent (AbsListView. java: 2124)
01-01 00:51:06. 320: ERROR/AndroidRuntime (4035): at android. widget. ListView. onTouchEvent (ListView. java: 3315)
01-01 00:51:06. 320: ERROR/AndroidRuntime (4035): at android. view. View. dispatchTouchEvent (View. java: 3918)
01-01 00:51:06. 320: ERROR/AndroidRuntime (4035): at android. view. ViewGroup. dispatchTouchEvent (ViewGroup. java: 898)
01-01 00:51:06. 320: ERROR/AndroidRuntime (4035): at android. view. ViewGroup. dispatchTouchEvent (ViewGroup. java: 937)
01-01 00:51:06. 320: ERROR/AndroidRuntime (4035): at android. view. ViewGroup. dispatchTouchEvent (ViewGroup. java: 937)

Solution: run it in the main thread, because the LISTVIEW loads the ADAPTER and runs it in AsyTask.

11. Database (2284): sqlite returned: error code = 14, msg = prepared
> Statement aborts at 4: [delete from android_metadata]
& Gt; Database (2284): DELETE failed setting locale
& Gt; Database (2284): Failed to setLocale () when constructing, closing
> Database
> Database (2284): android. database. sqlite. SQLiteException: unable to open
> Database file
> Database (2284):
> Android. database. sqlite. SQLiteDatabase. native_setLocale (Native Method)
> Database (2284):
> Android. database. sqlite. SQLiteDatabase. setLocale (SQLiteDatabase. java: 1950)
> Database (2284):
> Android. database. sqlite. SQLiteDatabase. <init> (SQLiteDatabase. java: 1818)
> Database (2284):
> Android. database. sqlite. SQLiteDatabase. openDatabase (SQLiteDatabase. java: 817)
> Database (2284):
> Android. database. sqlite. SQLiteDatabase. openOrCreateDatabase (SQLiteDatabase. java: 851)
> Database (2284):
> Android. database. sqlite. SQLiteDatabase. openOrCreateDatabase (SQLiteDatabase. java: 844)
> Database (2284):
> Android. app. ContextImpl. openOrCreateDatabase (ContextImpl. java: 542)
> Database (2284):
> Android. content. ContextWrapper. openOrCreateDatabase (ContextWrapper. java: 203)
> Database (2284):
> Android. database. sqlite. SQLiteOpenHelper. getWritableDatabase (SQLiteOpenHelper. java: 98)
> Database (2284):
> Android. database. sqlite. SQLiteOpenHelper. getReadableDatabase (SQLiteOpenHelper. java: 158)
> Database (2284):
> Com. android. providers. media. MediaProvider. query (MediaProvider. java: 1287)
> Database (2284):
> Com. android. providers. media. MediaProvider. attachVolume (MediaProvider. java: 3045)
> Database (2284):
> Com. android. providers. media. MediaProvider. insertInternal (MediaProvider. java: 1945)
> Database (2284):
> Com. android. providers. media. MediaProvider. insert (MediaProvider. java: 1665)
> Database (2284): at android. content. ContentProvider
> $ Transport. insert (ContentProvider. java: 174)
> Database (2284):
> Android. content. ContentResolver. insert (ContentResolver. java: 587)
> Database (2284):
> Com. android. providers. media. MediaScannerService. openDatabase (MediaScannerService. java: 65)
> Database (2284):
> Com. android. providers. media. MediaScannerService. scan (MediaScannerService. java: 113)
> Database (2284):
> Com. android. providers. media. MediaScannerService. access
> $400 (MediaScannerService. java: 53)
> Database (2284): at com. android. providers. media. MediaScannerService
> $ ServiceHandler. handleMessage (MediaScannerService. java: 283)
> Database (2284):
> Android. OS. Handler. dispatchMessage (Handler. java: 99)
> Database (2284): at android. OS. low.loop (low.java: 123)
> Database (2284):
> Com. android. providers. media. MediaScannerService. run (MediaScannerService. java: 197)
& Gt; Database (2284): at java. lang. Thread. run (Thread. java: 1096)
> SQLiteOpenHelper (2284): Couldn't open external. db for writing (will try
> Read-only ):
> SQLiteOpenHelper (2284): android. database. sqlite. SQLiteException: unable
> To open database file
> SQLiteOpenHelper (2284):
> Android. database. sqlite. SQLiteDatabase. native_setLocale (Native Method)
> SQLiteOpenHelper (2284):
> Android. database. sqlite. SQLiteDatabase. setLocale (SQLiteDatabase. java: 1950)
> SQLiteOpenHelper (2284):
> Android. database. sqlite. SQLiteDatabase. <init> (SQLiteDatabase. java: 1818)
> SQLiteOpenHelper (2284):
> Android. database. sqlite. SQLiteDatabase. openDatabase (SQLiteDatabase. java: 817)
> SQLiteOpenHelper (2284):
> Android. database. sqlite. SQLiteDatabase. openOrCreateDatabase (SQLiteDatabase. java: 851)
> SQLiteOpenHelper (2284):
> Android. database. sqlite. SQLiteDatabase. openOrCreateDatabase (SQLiteDatabase. java: 844)
> SQLiteOpenHelper (2284):
> Android. app. ContextImpl. openOrCreateDatabase (ContextImpl. java: 542)
> SQLiteOpenHelper (2284):
> Android. content. ContextWrapper. openOrCreateDatabase (ContextWrapper. java: 203)
> SQLiteOpenHelper (2284):
> Android. database. sqlite. SQLiteOpenHelper. getWritableDatabase (SQLiteOpenHelper. java: 98)
> SQLiteOpenHelper (2284):
> Android. database. sqlite. SQLiteOpenHelper. getReadableDatabase (SQLiteOpenHelper. java: 158)
> SQLiteOpenHelper (2284):
> Com. android. providers. media. MediaProvider. query (MediaProvider. java: 1287)
> SQLiteOpenHelper (2284):
> Com. android. providers. media. MediaProvider. attachVolume (MediaProvider. java: 3045)
> SQLiteOpenHelper (2284):
> Com. android. providers. media. MediaProvider. insertInternal (MediaProvider. java: 1945)
> SQLiteOpenHelper (2284):
> Com. android. providers. media. MediaProvider. insert (MediaProvider. java: 1665)
> SQLiteOpenHelper (2284): at android. content. ContentProvider
> $ Transport. insert (ContentProvider. java: 174)
> SQLiteOpenHelper (2284):
> Android. content. ContentResolver. insert (ContentResolver. java: 587)
> SQLiteOpenHelper (2284):
> Com. android. providers. media. MediaScannerService. openDatabase (MediaScannerService. java: 65)
> SQLiteOpenHelper (2284):
> Com. android. providers. media. MediaScannerService. scan (MediaScannerService. java: 113)
> SQLiteOpenHelper (2284):
> Com. android. providers. media. MediaScannerService. access
> $400 (MediaScannerService. java: 53)
> SQLiteOpenHelper (2284):
> Com. android. providers. media. MediaScannerService
> $ ServiceHandler. handleMessage (MediaScannerService. java: 283)
> SQLiteOpenHelper (2284):
> Android. OS. Handler. dispatchMessage (Handler. java: 99)
> SQLiteOpenHelper (2284): at android. OS. Looper. loop (Looper. java: 123)
> SQLiteOpenHelper (2284):
> Com. android. providers. media. MediaScannerService. run (MediaScannerService. java: 197)
& Gt; SQLiteOpenHelper (2284): at java. lang. Thread. run (Thread. java: 1096)
Solution: After DBHELPER opens the database link, it is not closed, resulting in a problem next time. At the same time, some users put the database into SDCARD, and they need to grant the SDCARD permission.

12. R appears in LINUX. When a JAVA file is not generated, the platform forms/android-8/tools under the SDK requires permissions.

Platforms/android-8/tools $ chmod a + x *

13: Problem description: E/WindowManager (5523): android. view. windowLeaked: Activity com. cardroid. sdhc. medialist. SDMediaListActivity has leaked window com. android. internal. policy. impl. phoneWindow $ DecorView @ 30c45e38 that was originally added here

Solution: A PhoneWindow cannot be destroyed in time. The current Activity is disabled. At the same time, dismiss was not promptly called to release ProgressDialog and so on, thus the system throws an error in the title, and masks the exception information that actually leads to this error. You need to disable some DIALOG when using the ONDESTORY method.

14: Problem description: You have added the permission to the configuration file when calling, but you are prompted to add the permission requires android. permission. CALL_PHONE.

W/dalvikvm (5709): threadid = 1: thread exiting with uncaught exception (group = 0x40015568)
W/ActivityManager (201): Permission Denial: starting Intent {
Act = android. intent. action. CALL dat = tel: xxx-xxxx cmp = com. android. phone/. OutgoingCall
Broadcaster} from ProcessRecord {408c2550 5709: com. um. mplus/10072} (pid = 5709, uid = 10072)
Requires android. permission. CALL_PHONE
E/AndroidRuntime (5709): fatal exception: main
E/AndroidRuntime (5709): java. lang. SecurityException: Permission Denial: starting Intent {
Act = android. intent. action. CALL dat = tel: xxx-xxxx cmp = com
. Android. phone/. OutgoingCallBroadcaster} from ProcessRecord {408c2550
5709: com. um. mplus/10072} (pid = 5709, uid = 10072) requires android. permission. CALL_PHONE

Solve the problem: because of this permission, some system-level restrictions are imposed, so you can add a capture exception.
1. If the R file of your project is missing, you can try to save the version number. The R file is usually caused by layout text errors.
2. The layout file cannot contain uppercase letters.
3. the following error is thrown: Application does not specify an API level requirement !,
Because the users sdk is not specified, modify the AndroidManifest. xml file.
Add: <uses-sdkandroid: minSdkVersion = "8"> </uses-sdk>
4. machine memory bottleneck. When apk is larger than our machine memory, the simulator will throw
Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE Please check logcat output for more details. Launch canceled!
This makes debugging impossible. Now we can solve this problem in two ways.
First (only the apk is smaller than the machine memory and has been installed on the current apk, but it cannot be debugged again)
Start the simulator and enter the menu
Settings-> applications-> mange
Applications-> select the application-> select "unistall ".
In this way, the apk can be completely deleted and re-installed.
Second (General)
-Partition-size 128
In Eclipse, add Options in the project Target.
5. When the android simulator is started, the following error occurs: Failed to install on device 'emulator-100': timeout.
This is possible because of the card cause startup timeout, solution: eclipse-> window-> Preferences-> Android-> DDMS-> ADB connection time out (MS ). set the time to a longer value. The default value is 5 seconds, that is, 5000 ms. if I change it to 10 seconds, it will be OK.
In this way, you do not need to restart the simulator every time. Specific time settings are based on actual environment requirements
6. During the development process, when the apk is installed on the simulator, an error is reported.
ActivityManager: Error: Activity class {...} does not exist.
There are two solutions to this problem:
Check whether the main Activity name contains the '.' character in the AndroidManifest. xml file.
7. This error occurs when you run Eclipse.
No Launcher activity found!
The launch will only sync the application package on the device!
Solution
Add in AndroidManifest. xml
<Category android: name = "android. intent. category. LAUNCHER"/>
8 the following error occurs: java. io. FileNotFoundException:/mnt/sdcard/update.zip (Permission denied)
Solution: Write the following permissions to resource files:
<Uses-permissionandroid: name = "android. permission. WRITE_EXTERNAL_STORAGE"/>


Tip: the typical bugs and solutions involved in this article are all summarized in my project as of now. Due to my limited working life, in the future, I may encounter other bugs in my actual work. I will continue to summarize the problems and solutions in my work. Therefore, this article will be updated in the future...

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.