无法实例化坐标资源系统java.lang.NoClassDefFoundError:org.geotools.factory.Hints

时间:2016-04-19 20:31:06

标签: android gradle geotools multidex

我正在尝试在我的项目中使用Geotools Java库,我使用Gradle和版本14.3构建它:

compile 'org.geotools:gt-shapefile:14.3'
compile 'org.geotools:gt-epsg-hsql:14.3'

基本上,每当我尝试实例化CoordinateResourceSystem时,例如:

CoordinateReferenceSystem crs;
try {
     crs = CRS.decode("epsg:4326"); //also tried DefaultGeographicCRS.WGS84_3D
} catch (FactoryException e) {
     e.printStackTrace();
}

我在运行时收到此错误:

java.lang.NoClassDefFoundError: org.geotools.factory.Hints
at org.geotools.referencing.CRS.<clinit>(CRS.java:181)

到目前为止,我收到的所有建议都与启用Multidex有关,我已经尝试过每一个gradle规定的组合,但无济于事。还尝试了几十次清洁和建设。无论我做什么,我都会在运行时收到这个麻烦的错误。有任何关于为什么会这样的想法?我可以在罐子里看到这个类。

我注意到这个依赖项导入了几个jar,所有jar都有类似的包名。这些包装名称会引起一些混淆吗?

这里真的不知所措,在我弄清楚如何正确实现这段代码之前,我无法继续我的项目。

修改

这是我的logcat。显示ART在处理某些geotools类时会出现某种问题,包括culrpit Hints类。

04-20 22:41:55.308 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.referencing.factory.ReferencingFactory>
04-20 22:41:55.311 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints>
04-20 22:41:55.311 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints$Key>
04-20 22:41:55.319 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints>
04-20 22:41:55.324 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.referencing.DefaultAuthorityFactory>
04-20 22:41:55.324 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.referencing.DefaultAuthorityFactory>
04-20 22:41:55.325 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints>
04-20 22:41:55.326 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints$Key>
04-20 22:41:55.326 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints$Key>
04-20 22:41:55.329 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints>
04-20 22:41:55.329 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.referencing.factory.AbstractAuthorityFactory>
04-20 22:41:55.330 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.referencing.factory.AbstractAuthorityFactory>
04-20 22:41:55.330 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints>
04-20 22:41:55.339 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.geometry.DirectPosition2D>
04-20 22:41:55.341 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints>
04-20 22:41:55.342 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints$Key>
04-20 22:41:55.355 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.357 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.358 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.359 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.360 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.361 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.362 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.363 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.363 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.364 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.365 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.366 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.367 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.368 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.371 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.372 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.374 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.375 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.376 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.376 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.377 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.378 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.378 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.379 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.379 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.383 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.384 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.384 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.389 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderableOp>
04-20 22:41:55.402 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.406 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderedOp>
04-20 22:41:55.406 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.PlanarImage>
04-20 22:41:55.408 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderableOp>
04-20 22:41:55.409 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderableOp>
04-20 22:41:55.410 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.RenderableOp>
04-20 22:41:55.414 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<javax.media.jai.JAI$RenderingKey>
04-20 22:41:55.414 5089-5089/com.myproject I/art: Rejecting re-init on previously-failed class java.lang.Class<org.geotools.factory.Hints>
04-20 22:41:55.414 5089-5089/com.myproject D/AndroidRuntime: Shutting down VM
04-20 22:41:55.415 5089-5089/com.myproject E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                               Process: com.myproject, PID: 5089
                                                                                               java.lang.NoClassDefFoundError: org.geotools.factory.Hints
                                                                                                   at org.geotools.referencing.CRS.<clinit>(CRS.java:181)
                                                                                                   at com.myproject.MotionTrackingActivity.onCreate(MotionTrackingActivity.java:122)
                                                                                                   at android.app.Activity.performCreate(Activity.java:5231)
                                                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2160)
                                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2246)
                                                                                                   at android.app.ActivityThread.access$800(ActivityThread.java:136)
                                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1197)
                                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                                   at android.os.Looper.loop(Looper.java:136)
                                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5030)
                                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)

1 个答案:

答案 0 :(得分:0)

打破GeoTools引用的“常用方法”是不包括EPSG工厂或包含多个工厂。从你的问题我不知道你的问题是什么。正如FAQ中所述,您需要其中一个epsg个罐子,通常为gt-epsg-hsql

您的问题标记为Android,并且some known issues有基于SPI的工厂查找系统,GeoTools使用但我不认为这应该是这个问题。