Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1514407
  • 博文数量: 129
  • 博客积分: 1449
  • 博客等级: 上尉
  • 技术积分: 3048
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-24 18:36
文章分类

全部博文(129)

文章存档

2015年(3)

2014年(20)

2013年(65)

2012年(41)

分类: Android平台

2014-04-15 11:58:56

1. ADT-22.3.0, 工程昨天运行OK, 今天早上未改动, 编译时出现错误如下:

04-15 02:47:55.256: D/AndroidRuntime(4576): Shutting down VM
04-15 02:47:55.256: W/dalvikvm(4576): threadid=1: thread exiting with uncaught exception (group=0x41547898)
04-15 02:47:55.256: E/AndroidRuntime(4576): FATAL EXCEPTION: main
04-15 02:47:55.256: E/AndroidRuntime(4576): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.http_cloud/com.example.http_cloud.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.http_cloud.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.http_cloud-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.http_cloud-1, /vendor/lib, /system/lib]]
04-15 02:47:55.256: E/AndroidRuntime(4576): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
04-15 02:47:55.256: E/AndroidRuntime(4576): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2264)
04-15 02:47:55.256: E/AndroidRuntime(4576): at android.app.ActivityThread.access$600(ActivityThread.java:144)
04-15 02:47:55.256: E/AndroidRuntime(4576): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1259)
04-15 02:47:55.256: E/AndroidRuntime(4576): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 02:47:55.256: E/AndroidRuntime(4576): at android.os.Looper.loop(Looper.java:137)
04-15 02:47:55.256: E/AndroidRuntime(4576): at android.app.ActivityThread.main(ActivityThread.java:5136)
04-15 02:47:55.256: E/AndroidRuntime(4576): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 02:47:55.256: E/AndroidRuntime(4576): at java.lang.reflect.Method.invoke(Method.java:525)
04-15 02:47:55.256: E/AndroidRuntime(4576): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
04-15 02:47:55.256: E/AndroidRuntime(4576): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-15 02:47:55.256: E/AndroidRuntime(4576): at dalvik.system.NativeStart.main(Native Method)
04-15 02:47:55.256: E/AndroidRuntime(4576): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.http_cloud.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.http_cloud-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.http_cloud-1, /vendor/lib, /system/lib]]
04-15 02:47:55.256: E/AndroidRuntime(4576): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
04-15 02:47:55.256: E/AndroidRuntime(4576): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-15 02:47:55.256: E/AndroidRuntime(4576): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-15 02:47:55.256: E/AndroidRuntime(4576): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
04-15 02:47:55.256: E/AndroidRuntime(4576): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2131)
04-15 02:47:55.256: E/AndroidRuntime(4576): ... 11 more
04-15 02:47:57.736: I/Process(4576): Sending signal. PID: 4576 SIG: 9

Manifest.xml肯定无问题, 

点击(此处)折叠或打开

  1. <manifest xmlns:android=""
  2.     package="com.example.http_cloud"
  3.     android:versionCode="1"
  4.     android:versionName="1.0" >

  5.     <uses-sdk
  6.         android:minSdkVersion="8"
  7.         android:targetSdkVersion="18" />
  8.       
  9.     <uses-permission android:name="android.permission.INTERNET" />

  10.     <application
  11.         android:icon="@drawable/ic_launcher"
  12.         android:label="@string/app_name"
  13.         android:theme="@style/AppTheme" >
  14.         
  15.         <activity
  16.             android:name="com.example.http_cloud.MainActivity"
  17.             android:label="@string/app_name" >
  18.             <intent-filter>
  19.                 <action android:name="android.intent.action.MAIN" />
  20.                 <category android:name="android.intent.category.LAUNCHER" />
  21.             </intent-filter>
  22.         </activity>
  23.     </application>

  24. </manifest>
折腾一上午, 试验了N种方法, 错误依然存在. 



2. import别人的工程, 错误如下: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.

原因:
代码本身会在你的项目下建立一个依赖包 Android Dependencies
解决: 工程中点右键 -> property-> Java Build Path, 右边的标签页选择Libraries, 下边的框中选择'android Dependencies', 再点击'Remove'即可. 

3. 06-13 09:09:39.638: E/AndroidRuntime(5505): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dweller/com.example.dweller.BluetoothChat}: java.lang.NullPointerException
06-13 09:09:39.638: E/AndroidRuntime(5505): Caused by: java.lang.NullPointerException
06-13 09:09:39.638: E/AndroidRuntime(5505): at com.example.dweller.BluetoothChat.db_init(BluetoothChat.java:765)
06-13 09:09:39.638: E/AndroidRuntime(5505): at com.example.dweller.BluetoothChat.onCreate(BluetoothChat.java:156)
06-13 09:09:39.638: E/AndroidRuntime(5505): at android.app.Activity.performCreate(Activity.java:5133)
06-13 09:09:39.638: E/AndroidRuntime(5505): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-13 09:09:39.638: E/AndroidRuntime(5505): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2178)
06-13 09:09:39.638: E/AndroidRuntime(5505): ... 11 more

在Java中一般报空指针异常的原因有以下几种: 
1字符串变量未初始化; 
2接口类型的对象没有用具体的类初始化,比如: 
List lt;会报错 
List lt = new ArrayList();则不会报错了 
3当一个对象的值为空时,你没有判断为空的情况。你可以试着把下面的代码前加一行代码: 
if(rb!=null && rb!="") 
改成: 
if(rb==null); 
if(rb!==null&&rb!="") 或者if((“”).equals(rb)) 
空指针的解决办法: 
       重点关注报错发生的所在行,通过空指针异常产生的两条主要原因诊断具体的错误。同时为了避免空指针的发生,最好在做判断处理时将“null”或者空值放于设定的值之前。 

//原因: 表中未赋值, 获取后为null. 

str_device_name = cursor.getString( cursor.getColumnIndex(SystemBean.NAME) );
str_device_name = str_device_name.trim();



阅读(2573) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~