如何调试混淆的Android代码?

时间:2014-02-23 23:22:01

标签: android

昨天我更新了我的Android应用程序之后,我从一些三星Galaxy Note II中得到了这个奇怪的错误。我有一些Note II设备,我无法自己复制这个问题。

(第97行是以标记开头的行)

我确信我的类正在扩展v4.fragment和FragmentActivity,因为它适用于我测试过的每个设备。但我仍然得到这些崩溃报告,我不知道如何解决这些问题。

有什么想法吗?

Java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zyz.mobile/com.zyz.mobile.jade.JadeActivity}: android.view.InflateException: Binary XML file line #97: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2362) at android.app.ActivityThread.access$700(ActivityThread.java:168) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1329) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5493) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #97: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719) at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) at android.view.LayoutInflater.inflate(LayoutInflater.java:498) at android.view.LayoutInflater.inflate(LayoutInflater.java:398) at android.view.LayoutInflater.inflate(LayoutInflater.java:354) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361) at android.app.Activity.setContentView(Activity.java:1956) at com.zyz.mobile.jade.JadeActivity.onCreate(Unknown Source) at android.app.Activity.performCreate(Activity.java:5372) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270) ... 11 more Caused by: java.lang.NullPointerException at com.zyz.mobile.jade.BookshelfFragment.a(Unknown Source) at android.support.v4.app.p.a(Unknown Source) at android.support.v4.app.p.b(Unknown Source) at android.support.v4.app.p.a(Unknown Source) at android.support.v4.app.h.onCreateView(Unknown Source) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691) ... 21 more

XML

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="20dp"
        >

    <com.zyz.mobile.widget.MyButton
            android:id="@+id/bookshelf_help"
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:background="@drawable/jade_button"
            android:textColor="@color/white"
            android:text="@string/help"
            android:textSize="20sp"
            android:layout_margin="1dp"
            android:gravity="bottom|left"
            />

    <com.zyz.mobile.widget.MyButton
            android:id="@+id/bookshelf_option"
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:background="@drawable/jade_button"
            android:textColor="@color/white"
            android:text="@string/option"
            android:textSize="20sp"
            android:layout_margin="1dp"
            android:gravity="bottom|left"
            />

    <com.zyz.mobile.widget.MyButton
            android:id="@+id/bookshelf_open"
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:background="@drawable/jade_button"
            android:textColor="@color/white"
            android:text="@string/open_book"
            android:textSize="20sp"
            android:layout_margin="1dp"
            android:gravity="bottom|left"
            />

</LinearLayout>
<com.zyz.mobile.widget.MyTextView
        android:id="@+id/history_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/history_title"
        android:textColor="@color/black"
        android:textSize="20sp"
        android:background="@color/grey"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:paddingLeft="10dp"
        />

<fragment
        class="com.zyz.mobile.jade.BookshelfFragment"
        android:id="@+id/bookshelf_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

1 个答案:

答案 0 :(得分:1)

如果查看堆栈跟踪,可以看到问题是由空指针异常引起的。

  

引起:java.lang.NullPointerException at   com.zyz.mobile.jade.BookshelfFragment.a(未知来源)

这是一个图书馆还是你写的东西?如果你得到了源代码,你可以在那里放一个断点,看看究竟是什么问题。

编辑:由于名为'a'的方法,我假设这是在具有ProGuard的构建中从Google Play报告的堆栈跟踪。 Please read about debugging obfuscated code traces here