最近一段时间在做 Android开发,用这篇贴子陆续记录自己Andoid开发问题及解决小结是个备忘小结,对其他学友或许也能带去帮助,好事就应该好好坚持,good luck!
当然对其中有疏漏的地方或没有解决的问题请看到的朋友多多反馈和指点.
(1)项目编译签名打包都正常, 测试机运行时闪退,报错如下,暂时还没找到解决办法:
12-03 18:23:29.195: E/dalvikvm(16777): Could not find class 'android.telephony.CellInfoWcdma', referenced from method com.tendcloud.tenddata.bb.t
12-03 18:23:29.252: E/AndroidRuntime(16777): FATAL EXCEPTION: main
12-03 18:23:29.252: E/AndroidRuntime(16777): java.lang.UnsatisfiedLinkError: Couldn't load jpush173 from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.hsw.zhangshangxian-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.hsw.zhangshangxian-1, /vendor/lib, /system/lib]]]: findLibrary returned null
12-03 18:23:29.252: E/AndroidRuntime(16777): at java.lang.Runtime.loadLibrary(Runtime.java:366)
12-03 18:23:29.252: E/AndroidRuntime(16777): at java.lang.System.loadLibrary(System.java:514)
12-03 18:23:29.252: E/AndroidRuntime(16777): at cn.jpush.android.service.PushProtocol.<clinit>(Unknown Source)
12-03 18:23:29.252: E/AndroidRuntime(16777): at cn.jpush.android.service.ServiceInterface.a(Unknown Source)
12-03 18:23:29.252: E/AndroidRuntime(16777): at cn.jpush.android.api.JPushInterface.init(Unknown Source)
12-03 18:23:29.252: E/AndroidRuntime(16777): at com.hsw.zhangshangxian.app.TouTiaoApplication.onCreate(TouTiaoApplication.java:109)
12-03 18:23:29.252: E/AndroidRuntime(16777): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1069)
12-03 18:23:29.252: E/AndroidRuntime(16777): at com.lbe.security.service.core.client.internal.InstrumentationDelegate.callApplicationOnCreate(InstrumentationDelegate.java:168)
12-03 18:23:29.252: E/AndroidRuntime(16777): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4670)
12-03 18:23:29.252: E/AndroidRuntime(16777): at android.app.ActivityThread.access$1300(ActivityThread.java:166)
12-03 18:23:29.252: E/AndroidRuntime(16777): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1434)
12-03 18:23:29.252: E/AndroidRuntime(16777): at android.os.Handler.dispatchMessage(Handler.java:107)
12-03 18:23:29.252: E/AndroidRuntime(16777): at android.os.Looper.loop(Looper.java:194)
12-03 18:23:29.252: E/AndroidRuntime(16777): at android.app.ActivityThread.main(ActivityThread.java:5400)
12-03 18:23:29.252: E/AndroidRuntime(16777): at java.lang.reflect.Method.invokeNative(Native Method)
12-03 18:23:29.252: E/AndroidRuntime(16777): at java.lang.reflect.Method.invoke(Method.java:525)
12-03 18:23:29.252: E/AndroidRuntime(16777): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
12-03 18:23:29.252: E/AndroidRuntime(16777): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
12-03 18:23:29.252: E/AndroidRuntime(16777): at dalvik.system.NativeStart.main(Native Method)
(2)android 异常处理--java.io.IOException: 您的主机中的软件中止了一个已建立的连接:
(3)列表显示Activity继承ListActivity时报错如下:
错误提示:Your content must have a ListView whose id attribute is'android.R.id.list'
对于以上错误,其实可能是因为我们要实现对ListView中setOnItemClick的事件监听而去继承了LiseActivity,但是却没有ListView的标签,只要在布局文件中添加定制Layout的代码,即将ListView的id设置为“@android:id/list”或android:id="@id/android:list",这时可以用getListView来获取ListView的对象了。
xml代码如下:
[html] view plaincopy<ListView
android:id="@android:id/list"或android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
(4).同样容易报此错误的还有TabHost,如下:
问题1.
添加Layout的时候,xml跟元素选择TabHost,但是ADT没有添加id属性, 运行的时候,会提示Your content must have a TabHost
whose id attribute is‘android.R.id.tabhost’错误, 需要添加android:id=”@android:id/tabhost”,这样就可以了。
问题2. 运行Activity的时候出现Your TabHostmust have a TabWidget whose id attribute is‘android.R.id.tabcontent’
解决方法: 修改FrameLayout添加id属性,ADT自动生成的xml文件中Id是android:id=”@+id/FrameLayout01 ”, 需要修改成下
面的格式android:id=”@android:id/tabcontent”,这个估计会困扰一大批初学者,谁会想到会修改这个地方,看到错误很容易
修改成tabcontent,但是前缀不容易想到。而且在ADT可视化编辑这个文件的时候, 界面上显示NullPointerException,这个是
ADT的一个BUG。
修改后的xml如下:
<?xml version=”1.0″encoding=”utf-8″?>
<TabHost
android:id=”@android:id/tabhost”
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”fill_parent”android:layout_height=”fill_parent”>
<LinearLayout android:id=”@+id/LinearLayout01″android:layout_height=”fill_parent”
android:layout_width=”fill_parent”android:orientation=”vertical”>
<TabWidgetandroid:id=”@android:id/tabs”android:layout_height=”wrap_content”
android:layout_width=”fill_parent”>
</TabWidget>
<FrameLayout android:id=”@android:id/tabcontent”android:layout_width=”fill_parent”
android:layout_height=”fill_parent”>
</FrameLayout>
</LinearLayout>
</TabHost>
注意: 如果用TabHost的话, 上面标红的三处必须是一样,这个是Google的约定。
(5)Genymotion eclipse 插件路径找不到问题:
(6)Genymotion使用报错: Installation error: INSTALL_FAILED_NO_MATCHING_ABIS