本文介绍了Android和ICU 5.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在我的Andr​​oid项目中使用ICU4J。但是,当我在设备上运行该项目,在发射,我有一个崩溃。
以下是错误:

 致命异常:主要
 java.lang.ExceptionInInitializerError
    在com.ibm.icu.text.SimpleDateFormat< clinit>(SimpleDateFormat.java:849)
    在com.ibm.icu.text.DateFormat.get(DateFormat.java:1492)
    在com.ibm.icu.text.DateFormat.getDateInstance(DateFormat.java:1191)
    在com.phonedev.myApp.calendar.TimeCursor.getLongDate(TimeCursor.java:333)
    在com.phonedev.myApp.about.VersionInfo.getBuildDateTime(VersionInfo.java:44)
    在com.phonedev.myApp.myAppActivity.onCreate(myAppActivity.java:184)
    在android.app.Activity.performCreate(Activity.java:5133)
    在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
    在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    在android.app.ActivityThread.access $ 600(ActivityThread.java:141)
    在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1256)
    在android.os.Handler.dispatchMessage(Handler.java:99)
    在android.os.Looper.loop(Looper.java:137)
    在android.app.ActivityThread.main(ActivityThread.java:5103)
    在java.lang.reflect.Method.invokeNative(本机方法)
    在java.lang.reflect.Method.invoke(Method.java:525)
    在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:737)
    在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    在dalvik.system.NativeStart.main(本机方法)
 java.util.MissingResourceException:引起找不到包COM / IBM / ICU / IMPL /数据/ icudt50b / EN_US
    在com.ibm.icu.impl.ResourceBundleWrapper.getBundleInstance(ResourceBundleWrapper.java:109)
    在com.ibm.icu.util.UResourceBundle.instantiateBundle(UResourceBundle.java:573)
    在com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:145)
    在com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:228)
    在com.ibm.icu.impl.CalendarData<&初始化GT;(CalendarData.java:28)
    在com.ibm.icu.util.Calendar.setWeekData(Calendar.java:4604)
    在com.ibm.icu.util.Calendar<&初始化GT;(Calendar.java:1584)
    在com.ibm.icu.util.GregorianCalendar<&初始化GT;(GregorianCalendar.java:391)
    在com.ibm.icu.util.GregorianCalendar<&初始化GT;(GregorianCalendar.java:337)
    在com.ibm.icu.text.DateFormat $外勤及LT; clinit>(DateFormat.java:1787)
    ... 20更多

似乎ICU来源需要更多的文件,但我说我在罐子里发现的所有源...
如果有人有同样的问题,或只是有解决方案......
谢谢!

编辑:
只是有这些警告:

  dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_root
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en_US
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_zoneinfo64
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en_US
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_supplementalData
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en_US
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_res
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en_US
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_res_index
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_ @历阳历='
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en
dvmFindClassByName拒绝COM / IBM / ICU / IMPL /数据/ icudt50b_en_US
主题ID = 11:螺纹未捕获的异常退出(组= 0x4176a700)


解决方案

好吧,我想通了这个问题的答案的问题。显然,你不能只是下载全力打造的.jar文件的ICU,只是删除它。它不包含数据的文件。

您的


  1. 下载.tgz文件复制,上面写着gzip压缩的tar归档在内的整个源代码包

  2. Uncom preSS该文件和CD到该目录

  3. 运行蚁族自己构建ICU4J

  4. 这将创建一个包含您所需要的数据文件icu4j.jar文件。您可以丢弃到您的libs目录,并修改你的gradle这个文件的build.gradle包括它

本来,如果这是在其网站上解释的地方或帮助,如果他们实际提供,其中包括数据文件的.jar文件。这引起了一整天头痛搞清楚,所以希望这可以帮助别人。

I started to use ICU4J in my Android project. But when I run the project on a device, at launch, I have a crash.Here is the error :

 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

It seems that ICU sources requires some more files, but I added all sources I found in the jar...If someone had the same problem or just has the solution...Thanks !

Edit:Just had these warnings :

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/icudt50b_@calendar=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)
解决方案

Ok I figured out the answer to this issue. Apparently you can not just download the fully built .jar file for ICU and just drop it in. It does not contain the data files.

You HAVE to:

  1. Download the .tgz file that says "gzipped tar archive including the entire source package"
  2. Uncompress that file and cd into that directory
  3. Run "ant" to build ICU4J yourself
  4. It will create a icu4j.jar file which contains the data files you need. You can drop that into your libs directory and amend your gradle build.gradle file to include it

Would have helped if this was explained somewhere on their site or if they actually provided a .jar file that included the data files. This caused about a day long headache to figure out so hopefully this helps someone else.

这篇关于Android和ICU 5.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 07:25