Bug records encountered in Andorid development project (cont.)

Source: Internet
Author: User

[22] Encountering query cannot be resolved to a variable error,

Resolution: 1. The variables defined in Java cannot be the same as the keywords in the System package (the case is different), the System package has a query, change the query 2. Whether the variable is defined as a local variable in the method, and cannot be used as the return value of the method as a different name

[23] Unable to execute Dex:multiple Dex files define landroid/support/v4/accessibilityservice/ Accessibilityserviceinfocompat$accessibilityserviceinfoversionimpl

Solve:

[24]java.lang.reflect.invocationtargetexception

Solve:

[25]java.net.connectexception:failed to connect to/***.***.***.*** (port): Connect Failed:ehostunreach (No route to H Ost

Resolution: The network is connected, but the network is blocked, disconnecting the reconnection

[26]android.widget.textview cannot is cast to Android.widget.CheckBox

Workaround: The TextView control in the layout file is overwritten,

[27]java.lang.runtimeexception:parcel:unable to marshal value {CLASSNAME}

Resolution: When jumping activity with intent, this error occurs, Intent.putextra ("Siteinfo", (Serializable) listsiteinfo); This line of code debugging passes, but cannot implement jump, throw error, The reason is that listsiteinfo is my own definition of a arraylist,siteinfo of type Siteinfo This class must inherit seralizable to be converted to a (Serializable) type.

[28] In the listener event executes the code of the asynchronous class Asynctask, if you want to get the results of the asynchronous class execution, and then continue to execute the following code in the Listener event, it is not advisable, because the asynchronous class Asynctask and your listener between the code running at the same time, If the subsequent code needs to use the results returned in the asynchronous class and then execute, it is not possible, because the code inside the asynchronous class executes, the code behind the listener event may have been executed, So it's best to write the code that needs to be executed later in the Asynctask async class inside the PostExecute execution

[29]android.view.windowmanager$badtokenexception:unable to add window-Token

Resolution: This error is caused by the new Alertdialog.builder (Mcontext), although the parameters here are Alertdialog.builder (context context) However, we cannot use the context obtained by Getapplicationcontext () and must use activity because there is only one activity to add a form. The parameters in the new Alertdialog.builder (context context) are populated with activity.this (the activity is the name of your activity) to create a dialog correctly.

[+] java.lang.RuntimeException:Unable to instantiate activity ComponentInfo exception

There are three things you can do to resolve an activity that cannot be instantiated: 1. The activity was not registered in the manifest.xml manifest, or the class name of the package name or activity was modified after the activity was created, and the configuration manifest was not modified to cause it to be instantiated. 2. Create a new package yourself, and the default package is still used when registering, for example, the default package is Com.ghg.Dao package, you create a new Com.ghg.DaoImpl package, and write a firstactivity in this package, when you register in Manifest.xml you write <activity android:name= ". Firstactivity "/>, at this time the equivalent of your class registered to the default package, the system is not found in the default package, because your firstactivity under the Com.ghg.DaoImpl package, so you should register as a package name plus class name, such as:< Activity android:name= "com.ghg.DaoImpl.FirstActivity" so that the system can find the corresponding class in the specified package. 3. It is also the case that your firstactivity is defined as an abstract class, which is not likely to be made by ordinary people. If the above three cases are taken into account, and the exception is thrown, check if the constructor and OnCreate () of the class exist in the activity class, and if so, then delete the constructor and put the initialization in OnCreate () to try.

[31]android.content.res.resources$notfoundexception:string Resource ID #0x0 The resource file ID could not be found #0x0

The reasons for this are as follows: In this case, it is possible to put an int business data set SetText () or similar method, so that the Android system will actively go to the resource file, but it is not a resource file ID, so will be reported this bug. Converts the int business data into a string type.

[32] When using the spinner control, you must bind the data to the spinner, otherwise report null pointer error, NULL value

[33.] does not display the system menu

Solution: Remove the android:targetsdkversion from the manifest to see if the menu is displayed

[34] When using the latest version of the ANDROIDSDK (4.x) and ADT plug-ins, the new Android project when the Red Fork and exclamation point use Adtbundle 20150202 version, the minimum version selected 4.0 or more

[35]eclipse's Invalid project description. Overlaps the location of another project

Solution: The project was downloaded in the workspace directory. The Eclipse plugin creates a directory with the same name in the workspace directory when the project is created. However, when the corresponding directory is found in the workspace directory, it will report the above error message, copy the project to other files and import

[36] Multimedia application development, the use of intent phone camera to take pictures and camera, if the intent when the specified mediastore.extra_output URI (file save location), Then the data returned in the Onactivityresult may be null

Solution: This is a different phone model of the problem, program: 1, do not manually specify the save path, let the system automatically default save 2. Manually specify the path, declare a global variable URI save path, in Onactivityresult cannot get URI with Data.getdata () method

[37] using control bindings inside fragment Onclicklistener Click event is invalid

Resolution: When using fragment or fragmentactivity, To set the Click event Listener for a control in a custom class that inherits from the fragment class must be in the Onactivitycreated method inside the fragment class to listen to the control binding, and in the Fragmenet class you can use Getactivity () method to get the activity of fragment

[38] de-edittext control automatically gets focus

FIX: Set focusable and Focusableintouchmode to true in EditText's parent control

[39]error:error parsing xml:unbound prefix

FIX: Custom controls When you add custom properties in Attrs.xml, use a custom control in a layout file, the name of the tag should be the package name of the custom control plus the class name, and the xmlns namespace that introduces the custom control (xmlns: custom property name = "/HTTP/ Schemas.android.com/apk/res/Package Name "(Main class package name/Custom control class package name?) )

[40]java.lang.noclassdeffounderror:android.support.v4.view.motioneventcompat

Solution: Android.support.v4.util.SparseArrayCompat, the problem is very strange, the jar package also has, the compilation also passed. However, there is a problem that the class cannot find at run time. Noclassdeffounderror This error is usually the corresponding class, not included in the corresponding apk. The Motioneventcompat class belongs to the ANDROID.SUPPORT.V4 extension library. Check the project Libraries directory and discover that the package was not introduced, right-click Project Properties-buildpath-libraries-add External Jar, locate the D:\eclipse\adt\sdk\extras\android\support\v7\appcompat\libs V4 package under the ADT plug-in file, and then in the order and Export inside to V4 hook, problem solving. (Low version of ADT, right-click Project Properties, check the "Android Private Libraries" front, then clean project, then compile and run)

[41] Unable to execute Dex:multiple Dex files define Landroid/support/annotation

Workaround: In the project, there is a class in the package name and the referenced jar package in the same class and package name, I use the class in the jar package, so this class in the project is a duplicate reference, delete the project repeatedly referenced class, successfully packaged start

[42] In layout file A, when using the <include layout= "@layout/mylayout"/> Tag, you can find the control on the Findviewbyid and set the listener event by a direct mylayout It is not valid to use Mylayout's view to bind an event to a control inside a mylayout.

[43] In the Baidu map above a layout file, in the map layout file to drag the map, the map will also move, the effect is very bad, just want to touch the map interface to let Baidu map mobile solution: Tried some methods, setfocusable, Setfocesableintouchmode, listen to a group of the suggestion of a netizen use framelayout, do not work, the back suddenly thought, in the clickable control above the view to drag the map, the map will not move, so, I set the clickable property to true for all of the layout files that are overlaid on the map, solve the problem!

Bug records encountered in Andorid development project (cont.)

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.