android--错误集锦

来源:互联网 发布:nginx iis 代理服务器 编辑:程序博客网 时间:2024/04/30 11:33

1. androidStudio中导入SVN项目

方法:vcs---- checkout from version control-----sunversion 点击加号添加SVN地址,选中项目点checkout,默认选中的path点OK----destination 选中SVN地址点OK----1.7format点OK。


2.Failure [INSTALL_FAILED_CPU_ABI_INCOMPATIBLE];

用的4.3的模拟器突然出现的这个问题。。    

 解决办法: 重新下载4.4.4的模拟器。下载了Genymotion-ARM-Translation.zip压缩包。运行模拟器,将下载的压缩包直接拖进模拟器的界面里。一直点OK直到成功。重新启动模拟器。在运行项目就可以了。


3.fragment小练习总结:
1). android.app.Fragment$InstantiationException: 
Unable to instantiate fragment com.example.fragmenttest.RightFragment: make sure class name exists, is public, and has an empty constructor that is public
-----------将RightFragment作为属性。出现下面的错误2)。

 2). Caused by: java.lang.InstantiationException: can't instantiate class com.example.fragmenttest.RightFragment; no empty constructor
----------添加了一个无参数的构造器。可以运行。但出现下面的问题3)。

3).  java.lang.ClassCastException: android.widget.TextView cannot be cast to android.view.ViewGroup
---------布局文件中把FrameLayout错写成fragment导致。要细心!

4. Caused by: android.view.InflateException: Binary XML file line #57: Error inflating class ViewPager

--------最后的原因是在实例化view对象的时候,ViewPager没有加包名

--------解决:android.support.v4.view.ViewPager


5.java.util.MissingFormatArgumentException: Format specifier: 3D

---------原因是在传入的参数值中带有“=”使用String.format(url,params)后把“=”自动转化为“%3D”导致参数错误。

---------解决是在url地址后直接拼上参数。不走format方法。


6.java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

--------原因是采用xml动态生成控件数组给父Linearlayout中添加时产生。


7.android.support.v4.app.SuperNotCalledException: Fragment AllDonateFragment{4474c388 #1 id=0x7f0d012b} did not call through to super.onActivityCreated()

---------解决是在fragment中的onActivityCreated()方法中,写上super.onActivityCreated()。


8.java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path

---------解决:在使用Gson解析json数据时。数据格式不对造成。


9.Error:Execution failed for task ':app:packageRelease'.

 > Unable to compute hash of/../AndroidStudioProjects/../classes.jar

---------解决:

All the current answers to this question are just giving the Proguard rules that worked for them, every fix will be different. First off, confirm it's a Proguard problem by checking that the classes-proguard directory is somewhere in the error message, something like this: Unable to compute hash of /Users/Documents/projectX/app/build/intermediates/classes-proguard/release/classes.jar

This means it's caused by an earlier Proguard error so you need to scroll up in the Messages window or Gradle Console window and check what warnings or errors you're getting. Just as an example, in my current project, Square's Picasso library is causing the error: Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient. I just added -dontwarn com.squareup.okhttp.** to ignore the warnings, and the app still worked as normal.

10. 进入页面直接显示最底部而不是顶部
-----解决:需在最外层LinearLayout中添加android:focusableInTouchMode="true"即可。


11.java.lang.ClassCastException: android.widget.HeaderViewListAdapter cannot be cast to android.widget.BaseAdapter

          在listview中添加header,在刷新adapter数据时,点击item会有数据越界的错误。

-----解决:HeaderViewListAdapter hlva = (HeaderViewListAdapter)l.getAdapter();
                       YourListAdapter postAdapter = (YourListAdapter )hlva.getWrappedAdapter();


12.在主项目中合并Library子项目的manifest文件。

-----解决:需要在项目中gradle.properties中设置manifestmerger.enabled=true即可;


13. 在自定义view中出现错误:Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]

-----解决: 需要在自定义view中重写两个参数的构造方法:MyView(Context context,AttributeSet attrs);---》(自定义view,如果view有属性,必须要重写这个方法)


0 0
原创粉丝点击