java - android studio,哪个导入语句使用外部库?

标签 java android android-studio import

我将 EJML 库添加到我的 android studio 项目中,但我不知道导入语句是什么样的。

我的意思是,我必须编写什么才能使用这些库?

enter image description here

我的依赖项:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile files('libs/EJML-core-0.30.jar')
compile files('libs/EJML-core-0.30-sources.jar')
compile files('libs/EJML-dense64-0.30.jar')
compile files('libs/EJML-dense64-0.30-sources.jar')
compile files('libs/EJML-denseC64-0.30.jar')
compile files('libs/EJML-denseC64-0.30-sources.jar')
compile files('libs/EJML-equation-0.30.jar')
compile files('libs/EJML-equation-0.30-sources.jar')
compile files('libs/EJML-simple-0.30.jar')
compile files('libs/EJML-simple-0.30-sources.jar')
compile files('libs/EJML-core-0.30-sources.jar')

最佳答案

在您的应用级 build.gradle 文件中,您将拥有一个 dependencies 部分。

参见 How to add local .jar file dependency to build.gradle file?了解更多信息。

所以在你的情况下你会:

dependencies {
    ... library files that are already there
    compile files('libs/EJML-core-0.30.jar')
    compile files('libs/EJML-core-0.30-sources.jar')
    ... the libraries in your libs folder will follow the same pattern
}

编辑:从评论中添加。

but i dont know how the import statement looks like: import ....

如果您只是使用 JAR 文件中的类,例如,如果我为 RecyclerView 添加依赖项(例如:compile 'com.android .support:recyclerview-v7:25.0.1') 然后我会调用 RecyclerView recyclerView = new RecyclerView() 等,它会要求你导入它在那里。我不知道您编译的JAR 需要哪些类。

关于java - android studio,哪个导入语句使用外部库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41287832/

相关文章:

android-studio - 如何增加编辑器字体大小?

java - 将随机数插入数组Java

java - 如何编写 Kafka 消费者——单线程 vs 多线程

java - Android重命名SQLite数据库

java - 将 Activity 元素的排列设置为从左到右(默认)

java - 使用 ADB 时 Android studio "File not found",桌面版有效

java - 如何将整数数组传递给需要 `Array<T>` 的方法?

java - 使用 Apache Spark 的 Hibernate 持久化导致进程阻塞

java - `file://` uri 前缀是我可以硬编码的吗?

android - 检查通知已在 android 中关闭