gpt4 book ai didi

java - 在android项目中添加外部依赖jar

转载 作者:行者123 更新时间:2023-11-30 10:27:12 25 4
gpt4 key购买 nike

我正在尝试将外部 jar 添加到我的 android 项目中。这些外部 jar 相互依赖,其中一些依赖于另一个 jar,因此当引用位于另一个 jar 文件中的类时,android studio 会为该类抛出 java.lang.NoClassDefFoundError。

在 android 项目中使用这些类型的 jar 的正确解决方案是什么??

  compile files('libs/gt-shapefile-2.7.5.jar')
compile files('libs/gt-metadata-2.7.5.jar')
compile files('libs/gt-data-2.7.5.jar')
compile files('libs/gt-main-2.7.5.jar')
compile files('libs/gt-api-2.7.5.jar')
compile files('libs/gt-referencing-2.7.5.jar')
compile files('libs/vecmath-1.3.2.jar')
compile files('libs/commons-pool-1.5.4.jar')
compile files('libs/gt-opengis-2.7.5.jar')
compile files('libs/jsr-275-1.0-beta-2.jar')
compile files('libs/jts-1.11.jar')
compile files('libs/jdom-1.0.jar')
compile files('libs/jai_core-1.1.3.jar')
compile files('libs/hsqldb-1.8.0.7.jar')
compile files('libs/gt-epsg-hsql-2.7.5.jar')

最佳答案

可以引用this回答以获得添加 jar 库的正确方法。

  1. First switch your folder structure from Android to Project. enter image description here enter image description here

  2. Now search for the libs folder inside app - build folder. enter image description here

  3. Once you have pasted the .jar file inside libs folder. Right click on the jar file and at end click on Add as library. This will take care of adding compile files('libs/library_name.jar') in build.gradle [You don't have to manually enter this in your build file]. enter image description here

    enter image description here

    Now you can start using the library in your project.

关于java - 在android项目中添加外部依赖jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45397171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com