2016-02-08 36 views
3

我的團隊遇到了一個奇怪的錯誤,我們的Android應用程序只會在我們嘗試在我們的Galaxy SIII測試手機上運行應用程序時崩潰。它可以在我們的其他兩款測試手機(S6和DROID)上正常工作。Android應用程序僅在Galaxy SIII上崩潰

該應用程序在運行時崩潰,出現未處理的異常,因爲它無法找到joda-time中引用的一些類 - 我們在build.gradle中聲明的項目依賴項。再一次,這個錯誤只有發生在我們的S3上,即使這樣,直到兩週前它仍在運行。

有了這種類型的問題,我可以通過很多方法來找出問題所在。不過,我已經開始遇到困難,並且會喜歡關於可能是什麼問題的任何想法/建議。

編輯2:我們確定了問題。我們沒有正確實例化multidex支持,並且該類未加載。

編輯:logcat的下面

W/dalvikvm: VFY: unable to find class referenced in signature (Lorg/joda/time/format/DateTimeFormatterBuilder;) 
W/dalvikvm: VFY: unable to find class referenced in signature (Lorg/joda/time/format/DateTimeFormatterBuilder;) 
E/dalvikvm: Could not find class 'org.joda.time.format.DateTimeFormat$StyleFormatter', referenced from method org.joda.time.format.DateTimeFormat.createDateTimeFormatter 
W/dalvikvm: VFY: unable to resolve new-instance 9443 (Lorg/joda/time/format/DateTimeFormat$StyleFormatter;) in Lorg/joda/time/format/DateTimeFormat; 
D/dalvikvm: VFY: replacing opcode 0x22 at 0x0005 
E/dalvikvm: Could not find class 'org.joda.time.format.DateTimeFormatterBuilder', referenced from method org.joda.time.format.DateTimeFormat.createFormatterForPattern 
W/dalvikvm: VFY: unable to resolve new-instance 9447 (Lorg/joda/time/format/DateTimeFormatterBuilder;) in Lorg/joda/time/format/DateTimeFormat; 
D/dalvikvm: VFY: replacing opcode 0x22 at 0x001a 
W/dalvikvm: VFY: unable to find class referenced in signature (Lorg/joda/time/format/DateTimeFormatterBuilder;) 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendEraText, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65094: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendEraText()Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x003c 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendCenturyOfEra, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65086: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendCenturyOfEra (II)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0042 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendTwoDigitYear, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65113: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendTwoDigitYear (IZ)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0075 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendTwoDigitWeekyear, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65112: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendTwoDigitWeekyear (IZ)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0084 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendYearOfEra, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65117: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendYearOfEra (II)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00ab 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendWeekyear, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65115: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendWeekyear (II)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00af 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendYear, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65116: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendYear (II)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00b3 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendMonthOfYearText, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65104: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendMonthOfYearText()Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00bd 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendMonthOfYearShortText, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65103: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendMonthOfYearShortText()Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00c2 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendMonthOfYear, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65102: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendMonthOfYear (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00c7 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendDayOfMonth, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65089: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendDayOfMonth (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00cc 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendHalfdayOfDayText, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65096: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendHalfdayOfDayText()Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00d1 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendClockhourOfHalfday, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65088: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendClockhourOfHalfday (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00d6 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendHourOfDay, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65097: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendHourOfDay (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00db 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendClockhourOfDay, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65087: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendClockhourOfDay (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00e0 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendHourOfHalfday, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65098: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendHourOfHalfday (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00e5 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendMinuteOfHour, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65101: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendMinuteOfHour (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00ea 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendSecondOfMinute, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65106: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendSecondOfMinute (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00ef 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendFractionOfSecond, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65095: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendFractionOfSecond (II)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00f4 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendDayOfWeek, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65090: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendDayOfWeek (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x00f9 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendDayOfWeekText, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65092: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendDayOfWeekText()Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0101 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendDayOfWeekShortText, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65091: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendDayOfWeekShortText()Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0106 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendDayOfYear, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65093: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendDayOfYear (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x010b 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendWeekOfWeekyear, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65114: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendWeekOfWeekyear (I)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0110 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendTimeZoneName, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65108: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendTimeZoneName()Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0118 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendTimeZoneShortName, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65111: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendTimeZoneShortName (Ljava/util/Map;)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x011e 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendTimeZoneOffset, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65109: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendTimeZoneOffset (Ljava/lang/String;Ljava/lang/String;ZII)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x74 at 0x012d 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendTimeZoneOffset, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65109: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendTimeZoneOffset (Ljava/lang/String;Ljava/lang/String;ZII)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x74 at 0x013c 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendTimeZoneId, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65107: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendTimeZoneId()Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0141 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendLiteral, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65099: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendLiteral (C)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0157 
I/dalvikvm: Could not find method org.joda.time.format.DateTimeFormatterBuilder.appendLiteral, referenced from method org.joda.time.format.DateTimeFormat.parsePatternTo 
W/dalvikvm: VFY: unable to resolve virtual method 65100: Lorg/joda/time/format/DateTimeFormatterBuilder;.appendLiteral (Ljava/lang/String;)Lorg/joda/time/format/DateTimeFormatterBuilder; 
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0161 
W/dalvikvm: VFY: unable to find class referenced in signature (Lorg/joda/time/format/InternalPrinter;) 
E/dalvikvm: Could not find class 'org.joda.time.format.DateTimeFormat$StyleFormatter', referenced from method org.joda.time.format.DateTimeFormat.patternForStyle 
W/dalvikvm: VFY: unable to resolve check-cast 9443 (Lorg/joda/time/format/DateTimeFormat$StyleFormatter;) in Lorg/joda/time/format/DateTimeFormat; 
D/dalvikvm: VFY: replacing opcode 0x1f at 0x000e 
D/dalvikvm: DexOpt: unable to opt direct call 0xfdef at 0x07 in Lorg/joda/time/format/DateTimeFormat;.createDateTimeFormatter 
D/dalvikvm: DexOpt: unable to opt direct call 0xfe3d at 0x1c in Lorg/joda/time/format/DateTimeFormat;.createFormatterForPattern 
D/AndroidRuntime: Shutting down VM 
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41799da0) 
D/HockeyApp: Writing unhandled exception to: /data/data/advancetransit.advancetransit/files/ca1894c1-c19a-49ea-acbe-bf74fc934521.stacktrace 
E/AndroidRuntime: FATAL EXCEPTION: main 
                      Process: advancetransit.advancetransit, PID: 6151 
                      java.lang.NoClassDefFoundError: org.joda.time.format.DateTimeFormatterBuilder 
                       at org.joda.time.format.DateTimeFormat.createFormatterForPattern(DateTimeFormat.java:686) 
                       at org.joda.time.format.DateTimeFormat.forPattern(DateTimeFormat.java:177) 
                       at advancetransit.advancetransit.models.StopTime.timeDifference(StopTime.java:116) 
                       at advancetransit.advancetransit.ui.activities.MainActivity.onStopSelect(MainActivity.java:1678) 
                       at advancetransit.advancetransit.ui.activities.MainActivity$GetLiveData.onPostExecute(MainActivity.java:970) 
                       at advancetransit.advancetransit.ui.activities.MainActivity$GetLiveData.onPostExecute(MainActivity.java:785) 
                       at android.os.AsyncTask.finish(AsyncTask.java:632) 
                       at android.os.AsyncTask.access$600(AsyncTask.java:177) 
                       at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645) 
                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                       at android.os.Looper.loop(Looper.java:146) 
                       at android.app.ActivityThread.main(ActivityThread.java:5487) 
                       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:1283) 
                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
                       at dalvik.system.NativeStart.main(Native Method) 
01-28 16:47:38.974 6151-6158/advancetransit.advancetransit I/AndroidRuntime: VM exiting with result code 1, cleanup skipped. 
+0

郵政logcat的位置。順便說一句,如果你正在開發的android你應該使用https://github.com/dlew/joda-time-android而不是喬達時間。 –

+0

嗨@SandroMachado,謝謝你的迴應。我在logcat中編輯過。我們絕對可以嘗試使用joda-time-android。除非專門爲它設計,否則java插件通常與Android有問題嗎? –

+0

這不是典型的,但有些情況下,java庫在android上工作需要進行一些更改。你可以閱讀項目描述爲什麼你應該使用joda-time-android而不是joda-time。 –

回答

1

從標準JodaTime更改爲JodaTime Android的端口不解決問題。 正如@ coder-con所解釋的,這個問題與MultiDex支持不正確的設置有關。 要設置multidex,你需要(如Android Developer解釋):

  1. 編輯您的build.gradle並添加mutliDexEnabled truecompile 'com.android.support.multidex:1.01'

    android { 
        ... 
        defaultConfig { 
         ... 
         // Enabling multidex support. 
         multiDexEnabled true 
        } 
    ... 
    } 
    dependencies { 
        compile 'com.android.support:multidex:1.0.1' 
    } 
    
  2. 在你AndroidManifest.xml,如果設置應用程序的名稱,以android.support.multidex.MultiDexApplication沒有你自己的應用程序類。否則,無論是擴展這個類,或者重寫attachBaseContext這樣的:(See details here

    protected void attachBaseContext(Context base) { 
        super.attachBaseContext(base); 
        MultiDex.install(this); 
    
+0

我不明白如何簡單地啓用Multidex來解決問題。包括JodaTime在內的65k方法限制並未受到影響,所以肯定還有其他的東西會導致錯誤 –

+0

@ cricket_007,一個錯誤配置的Multidex適用於最近的設備/操作系統,但不適用於像S3那樣的舊版本,其中包括com。 adnroid.support:multidex:1.0.1'是強制性的。所以,問題出現在了那裏,但是直到在舊設備/操作系統上測試之後才被忽視。 – DenisGL

+0

是@DenisGL,這正是發生了什麼事。 –