繁体   English   中英

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

[英]android studio, which import statement to use external libs?

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

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

在此处输入图片说明

我的依赖:

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部分。

请参阅如何将本地.jar文件依赖项添加到build.gradle文件? 欲获得更多信息。

因此,在您的情况下,您将拥有:

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 ....

如果您只使用JAR文件中的类,例如,如果我添加了RecyclerView的依赖项(例如: compile 'com.android.support:recyclerview-v7:25.0.1' : recyclerView = new RecyclerView() compile 'com.android.support:recyclerview-v7:25.0.1' : compile 'com.android.support:recyclerview-v7:25.0.1' ),那么我将调用RecyclerView recyclerView = new RecyclerView()等,它会要求您将其导入那里。 我不知道您已编译的JARs需要什么类。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM