2013-08-07 76 views
7

我開始在我的Android項目中使用ICU4J。但是當我在設備上運行項目時,發生崩潰。 以下是錯誤:Android和ICU 5.0

FATAL EXCEPTION: main 
java.lang.ExceptionInInitializerError 
    at com.ibm.icu.text.SimpleDateFormat.<clinit>(SimpleDateFormat.java:849) 
    at com.ibm.icu.text.DateFormat.get(DateFormat.java:1492) 
    at com.ibm.icu.text.DateFormat.getDateInstance(DateFormat.java:1191) 
    at com.phonedev.myApp.calendar.TimeCursor.getLongDate(TimeCursor.java:333) 
    at com.phonedev.myApp.about.VersionInfo.getBuildDateTime(VersionInfo.java:44) 
    at com.phonedev.myApp.myAppActivity.onCreate(myAppActivity.java:184) 
    at android.app.Activity.performCreate(Activity.java:5133) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 
    at android.app.ActivityThread.access$600(ActivityThread.java:141) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:5103) 
    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:737) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
    at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.util.MissingResourceException: Could not find the bundle com/ibm/icu/impl/data/icudt50b/en_US 
    at com.ibm.icu.impl.ResourceBundleWrapper.getBundleInstance(ResourceBundleWrapper.java:109) 
    at com.ibm.icu.util.UResourceBundle.instantiateBundle(UResourceBundle.java:573) 
    at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:145) 
    at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:228) 
    at com.ibm.icu.impl.CalendarData.<init>(CalendarData.java:28) 
    at com.ibm.icu.util.Calendar.setWeekData(Calendar.java:4604) 
    at com.ibm.icu.util.Calendar.<init>(Calendar.java:1584) 
    at com.ibm.icu.util.GregorianCalendar.<init>(GregorianCalendar.java:391) 
    at com.ibm.icu.util.GregorianCalendar.<init>(GregorianCalendar.java:337) 
    at com.ibm.icu.text.DateFormat$Field.<clinit>(DateFormat.java:1787) 
    ... 20 more 

看來,ICU的來源需要更多的文件,但我說我在罐子裏發現的所有源... 如果有人有同樣的問題,或只是有解決方法.. 。 謝謝!

編輯: 剛剛有了這些警告:

dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_root' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en_US' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_zoneinfo64' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en_US' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_supplementalData' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en_US' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_res' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en_US' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_res_index' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/[email protected]=gregorian' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en' 
dvmFindClassByName rejecting 'com/ibm/icu/impl/data/icudt50b_en_US' 
threadid=11: thread exiting with uncaught exception (group=0x4176a700) 
+0

你有沒有找到答案?我有同樣的問題 –

回答

4

好吧,我想通了這個問題的答案的問題。顯然,你不能只下載ICU的完整的.jar文件,只需將其放入。它不包含數據文件。

HAVE到:

  1. 下載.tgz的文件,上面寫着「gzip壓縮的tar歸檔在內的整個源代碼包」
  2. 解壓縮該文件,並cd進入這個目錄
  3. 運行「螞蟻「自己構建ICU4J
  4. 它將創建一個包含所需數據文件的icu4j.jar文件。你可以丟棄到您的libs目錄,並修改你的gradle這個的build.gradle文件,包括它

本來,如果這是在其網站上解釋的地方,或者如果他們確實提供了包括數據文件.jar文件幫助。這導致了長達一天頭痛,希望這可以幫助別人。

+1

是的謝謝!這就是我所做的。但是,這對我來說是一個糟糕的解決方案,因爲瓶子太重了......過去從7Mb到16Mb(大約) –

+0

不,謝謝,我的應用程序的整個尺寸小於3MB ... – Pedram