在使用 BaseAdapter 的问题
java.lang.IllegalArgumentException: The observer is null.
at android.database.Observable.unregisterObserver(Observable.java:64)
at android.widget.BaseAdapter.unregisterDataSetObserver(BaseAdapter.java:42)
at android.widget.AbsListView.onDetachedFromWindow(AbsListView.java:2872)
at android.view.View.dispatchDetachedFromWindow(View.java:11908)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2647)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2645)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2645)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2645)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2645)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2645)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2645)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2645)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2645)
at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2685)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:4044)
at android.view.ViewRootImpl.die(ViewRootImpl.java:4027)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:375)
at android.view.WindowManagerImpl$CompatModeWrapper.removeViewImmediate(WindowManagerImpl.java:170)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3352)
at android.app.ActivityThread.access$1200(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1266)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4914)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:808)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:575)
at dalvik.system.NativeStart.main(Native Method)
复制代码
解决方法,继承 BaseAdapter 的时候写入
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
if (observer != null) {
super.unregisterDataSetObserver(observer);
}
}
复制代码
2.从网上新下载一个项目,导入到 eclipse 中运行时,报错:
java.lang.NoClassDefFoundError: com.baidu.mapapi.BMapManager
复制代码
解决方案:一、右击项目->properties->Java Build Path->Order and Export,在需要引用的包前面打勾。二、Project->Clean...问题解决,重新运行后就没什么问题了
3.华为手机 debug 需要打开 log 开关方法:1、在拨号界面输入:##2846579## 进入测试菜单界面 2、Project Menu–后台设置–LOG 设置 3、LOG 开关–LOG 打开 LOG 级别设置–VERBOSE4、Dump&Log– 全部选中 5、重启手机,重启 Eclipse
4.未知异常
java.lang.UnsatisfiedLinkError: Couldn't load zbar from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.haigou.client-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.haigou.client-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.zbar.lib.ZbarManager.<clinit>(ZbarManager.java:15)
at com.zbar.lib.decode.DecodeHandler.decode(DecodeHandler.java:56)
at com.zbar.lib.decode.DecodeHandler.handleMessage(DecodeHandler.java:38)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at com.zbar.lib.decode.DecodeThread.run(DecodeThread.java:44)
复制代码
解决方式: 负责 armeabi 中的.so 文件拷贝到 armeabi-v7a
5.未知异常
import com.sun.image.codec.jpeg.JPEGCodec
复制代码
不通过 找不到包在 Eclipse 中处理图片,需要引入两个包:
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
复制代码
报错:
Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
复制代码
此时解决办法:Eclipse 默认把这些受访问限制的 API 设成了 ERROR。只要把 Windows-Preferences-Java-Complicer-Errors/Warnings 里面的 Deprecated and restricted API 中的 Forbidden references(access rules)选为 Warning 就可以编译通过。
6.未知异常
Don't call setOnClickListener for an AdapterView
复制代码
不能再 AdapterView 不能设置 onClickListener,否则会直接抛出异常
7.eclipse 项目导入异常 1,右键项目名称
BuildPath ---> Configure Build Paht...中,然后上面有几个选项卡找到 Libraries 中出现红色叉号的包为路径错误的包。到 classpath 中修改相应包的当前路径。然后回到 eclipse 中 F5 刷新工程。不行的话可以试试 clean 项目;project--->clean 如果你的 eclipse 项目有红色叹号,而 Libraries 中没有出现红色叉号的包,我是这样做的。1,先把 eclipse 转换到 Markers 视图,windows---->show view ---->markers 会发现这些报错内容,Archive for required library: ‘XXXXXXXX001’ in project ‘xxxxxxxxx’ cannot be read or is not a valid ZIP file2,用记事本打开项目根目录的.classpath 文件,找到“<classpathentry kind="lib" path="XXXXXXXXX001"/>”这一行,删掉保存,刷新后,这个报错就没有了,从而红色叹号也没有了。
8.eclipse 打包时字符串多国语言处理打包时字符串多国语言问题(Checks for incomplete translations where not all stAndroid Lint Preference -- ignore all
9.未知异常
java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{4278dfe8 V.E..... R.....ID 0,0-1248,288} not attached to window manager
at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:370)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:299)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
at android.app.Dialog.dismissDialog(Dialog.java:329)
at android.app.Dialog.dismiss(Dialog.java:312)
at android.app.Dialog.cancel(Dialog.java:1114)
at com.haigou.activity.MainActivity$WebHandler.handleMessage(MainActivity.java:964)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5034)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:807)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:623)
at dalvik.system.NativeStart.main(Native Method)
复制代码
异步消息造成的问题
10.未知异常
Conversion to Dalvik format failed: Unable to execute dex:
复制代码
两个包有内容重复或冲突之类,同一项目中多次引用或者多次导包导致冲突
11.未知异常
Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
复制代码
选择你的应用,右键选择【run as】--【run configurations】--【target】--【Additional Emulator Command Line Options】,填写“-partition-size 256”
12.addview() 不执行 removeView 会报出异常,addView 后,你要添加的 view 就一直存在添加 view 的容器中,不 removeView 不会有什么情况,是不过在你要想在 addView 上次的 view 之前必须先把 removeView 掉,否则会提示你 view 已存在异常。
评论