Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2091329
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: 嵌入式

2011-04-02 11:26:28

  1. Docs
    • http://developer.android.com/guide/developing/debugging/index.html
    • How to debug on device
      http://developer.android.com/guide/developing/device.html
    • Reading and Writing Logs
      http://developer.android.com/guide/developing/debugging/debugging-log.html
    • xxx
  2. Tools
    • adb (Android Debug Bridge
      • ps
      • logcat
    • ddms (Dalvik Debug Monitor Server
      • Capture screenshots
      • Send sms to monitor
      • Trigger call to monitor
      • ...
    • Log (Write log in code)
      • logcat
    • Try-catch-finally, and then you can print stack trace with Throwable.printStackTrace(xxx).
    • gdb
      (Reference: http://blog.csdn.net/mayqlzu/article/details/5669241)

      启动模拟器

      $emulator

      进入device

      $adb shell

      从模拟器点击启动Browser

      看看它的process id是多少

      #ps

      记住你要的pid

      启动gdbserver, 指定在哪个prot上监听client,指定调试哪个进程

      #gdbserver :5039 --attach pid

      开始cient端的工作

      On your workstation, forward port 5039 to the device with adb: 不知道怎么翻译

      打开一个新的终端

      $adb forward tcp:5039 tcp:5039

      $cd ~/mydroid

      找一个最新版本的arm-eabi-gdb

      $find -name arm-eabi-gdb

      记住path

      启动gdbclient

      $/home/peipei/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gdb /home/peipei/mydroid/out/target/product/generic/symbols/system/bin/app_process

      In gdb, Tell gdb where to find the shared libraries that will get loaded:

      (gdb)set solib-absolute-prefix /home/peipei/mydroid/out/target/product/generic/symbols

      (gdb)set solib-search-path /home/peipei/mydroid/out/target/product/generic/symbols/system/lib

      小心,路径别写错,如果错了,gdb是不会告诉你的。

      另外,要注意,两个路径都要指向symbols目录。

      Connect to the device by issuing the gdb command:

      (gdb)target remote :5039

      The :5039 tells gdb to connect to the localhost port 5039, which is bridged to the device by adb.

      You may need to inspire gdb to load some symbols by typing:

      (gdb)shared
    • xx
  3. FAQ
    • Debug on Device
      Window: Install USB driver for the device
      Linux: Add USB configure file under /etc/udev/xxx following the steps at http://developer.android.com/guide/developing/device.html, and then execute 'adb usb && adb kill-server && adb start-server' as super user.

    • [Q] Can't find proguard.cfg under /tools/lib when to create Android project.
      [A]
      1st Way:
         - Eclipse--->Window--->Android SDK And AVD Manager(或者直接在Android解压目录底下运行SDK Setup.exe)
         - 选择installed packages,在右边列表中选择SDK tools ,点击 update all

      2nd Way:
      Create the file proguard.cfg with the following contents:

      -optimizationpasses 5
      -dontusemixedcaseclassnames
      -dontskipnonpubliclibraryclasses
      -dontpreverify
      -verbose
      -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

      -keep public class * extends android.app.Activity
      -keep public class * extends android.app.Application
      -keep public class * extends android.app.Service
      -keep public class * extends android.content.BroadcastReceiver
      -keep public class * extends android.content.ContentProvider
      -keep public class com.android.vending.licensing.ILicensingService

      -keepclasseswithmembernames class * {
          native ;
      }

      -keepclasseswithmembernames class * {
          public (android.content.Context, android.util.AttributeSet);
      }

      -keepclasseswithmembernames class * {
          public (android.content.Context, android.util.AttributeSet, int);
      }

      -keepclassmembers enum * {
          public static **[] values();
          public static ** valueOf(java.lang.String);
      }

      -keep class * implements android.os.Parcelable {
        public static final android.os.Parcelable$Creator *;
      }
    • [Q]When to run application on Android Emulator 2.0, Android reports error:
      android.view.InflateException: Binary XML file line #xxx: Error inflating class xxx"
      ...................
      android.content.res.Resources$NotFoundException: File res/drawable/title_bar_shadow.9.png from drawable resource ID xxx
      ................


      The details error messages are:
      =================================
      08-01 21:03:10.510: ERROR/AndroidRuntime(914): Uncaught handler: thread main exiting due to uncaught exception
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tek.apps.android.theawayteam/com.tek.apps.android.blah.Blahhome}: android.view.InflateException: Binary XML file line #2: Error inflating class java.lang.reflect.Constructor
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.app.ActivityThread.access$1800(ActivityThread.java:112)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.os.Handler.dispatchMessage(Handler.java:99)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.os.Looper.loop(Looper.java:123)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.app.ActivityThread.main(ActivityThread.java:3948)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at java.lang.reflect.Method.invokeNative(Native Method)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at java.lang.reflect.Method.invoke(Method.java:521)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at dalvik.system.NativeStart.main(Native Method)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class java.lang.reflect.Constructor
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.view.LayoutInflater.createView(LayoutInflater.java:512)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.app.Activity.setContentView(Activity.java:1626)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at com.tek.apps.android.theawayteam.football.FootballHome.onCreate(FootballHome.java:17)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): … 11 more
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): Caused by: java.lang.reflect.InvocationTargetException
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.widget.LinearLayout.(LinearLayout.java:92)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at java.lang.reflect.Constructor.constructNative(Native Method)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.view.LayoutInflater.createView(LayoutInflater.java:499)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): … 21 more
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/title_bar_shadow.9.png from drawable resource ID #0x7f02000c
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.content.res.Resources.loadDrawable(Resources.java:1641)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.view.View.(View.java:1725)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.view.View.(View.java:1674)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.view.ViewGroup.(ViewGroup.java:271)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): … 25 more
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): Caused by: java.io.FileNotFoundException: res/drawable/title_bar_shadow.9.png
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.content.res.AssetManager.openNonAssetNative(Native Method)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.content.res.AssetManager.openNonAsset(AssetManager.java:392)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): at android.content.res.Resources.loadDrawable(Resources.java:1634)
      08-01 21:03:10.550: ERROR/AndroidRuntime(914): … 29 more

      [A]Its looks like a packing/extraction problem. The way to solve this is to rename your drawable-mdpi folder to drawable.
    • xxx
  4. xxx
阅读(2303) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~