Bug set and solution, bug set Solution
1,
Java. lang. IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 278
Solution: The interface data format is different from the object data format.
2,
Java. lang. RuntimeException: Unable to start activity ComponentInfo {com. wangll. activity/com. wangll. activity. MainActivityPerson }:
Caused by: java. lang. NullPointerException
At android. support. v7.app. ActionBarImplICS. getDisplayOptions (ActionBarImplICS. java:
Solution: Android4.4 ActionBar
3,
Fragment (XXFragment) not attached to Activity
Solution:
Content 1: Fragment (XXFragment) not attached to Activity is abnormal. This exception occurs because when the Fragment has not been Attach to the Activity, the getResource () function is called and the context Content function is required. The solution is to write the called code in OnStart. There are a few such reference online: http://stackoverflow.com/questions/10919240/fragment-myfragment-not-attached-to-activity answer is mainly in the call
[Java] view plaincopy
GetResources (). getString (R. string. app_name );
[Java] view plaincopy
GetResources (). getString (R. string. app_name );
Before adding a judgment isAdded (), there is a http://stackoverflow.com/questions/6870325/android-compatibility-package-fragment-not-attached-to-activity for both sides to say this exception Solution
This is an alternative solution.
2. When you use Fragment to save parameters, it may be because the parameters to be saved are large or large. In this case, the page may cause an exception. For example, code
[java] view plaincopy Bundle b = new Bundle(); b.putParcelable("bitmap", bitmap2); imageRecognitionFragment.setArguments(b); [java] view plaincopy Bundle b = new Bundle(); b.putParcelable("bitmap", bitmap2);
After you set the parameters and add hide () and add (), you need to commit () to implement two Fragment redirects. In this case, the parameters must be saved by the system, however, at this time, you have implemented redirection, but the system parameters are not saved. At this time, it will be reported
Java. lang. IllegalStateException: Can not perform this action after onSaveInstanceState
Exception. Cause Analysis: you do not need to save the system parameters. As long as the parameters you set can be passed in and accepted in another Fragment, now, android provides another submission method in the form of commitAllowingStateLoss (). We can see from the name that this submission allows loss of status values. The problem can be solved perfectly, and the transfer of values is controlled by yourself.
Another problem is also mentioned here. bitmap can also be passed through Bundle. You can use putParacelable.
4,
AndroidRuntime (11108 ):
Caused by: java. lang. ClassNotFoundException:
Com. example. demos_tabviewpger.
MainActivity in loader dalvik. system. PathClassLoader [/data/app/com.example.demos_tabviewpger-2.apk]
Solution: I think we often encounter ClassNotFoundException exceptions due to negligence. In android development, this exception is nothing more than telling you that the class is not found. Why can't it be found?
In fact, there are two situations:
1. When the activity is started. in xml, you may have forgotten to add an activity, or the package name or name of the activity is wrong. This error is highly likely. 2. Your class, it is an external JAR package. When it is compiled and used in the project, it is published as an APK and does not contain the JAR file. Therefore, when the APK is executed, the JAR file cannot be found and an error is returned.
Therefore, you must check the jar package in "Order and Export. Remember!
5,
Java. lang. IllegalStateException:
The application's PagerAdapter changed the adapter's
Contents without calling PagerAdapter # notifyDataSetChanged!
Expected adapter item count: 0, found: 3 Pager id:
Solution:
When initializing ViewPager, initialize the content of the Adapter first, and then pass the adapter to ViewPager,
If not, call the notifyDataSetChanged method of the adapter after updating the content of the adapter,
Otherwise, The application's PagerAdapter changed the adapter's contents without calling PagerAdapter # notifyDataSetChanged exception will be reported when you use ADT22 or later,