android studio,哪个import语句使用外部库?

时间:2016-12-22 16:37:02

标签: java android android-studio import

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

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

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')

}

1 个答案:

答案 0 :(得分:2)

在您的应用级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
}
从评论中添加了

修改

  

但我不知道import语句的样子:import ....

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