简体   繁体   中英

android studio, which import statement to use external libs?

I added the EJML library to my android studio project, but i dont know how the import statement looks like.

I mean, what do i have to write to use these libraries?

在此处输入图片说明

my dependencies:

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

}

In your app level build.gradle file, you'll have a dependencies section.

see How to add local .jar file dependency to build.gradle file? for more information.

So in your case you would have:

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
}

Edit: added from comments.

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

if you just use a class from the JAR files, so for example if I add a dependency for a RecyclerView (example: compile 'com.android.support:recyclerview-v7:25.0.1' ) I would then call RecyclerView recyclerView = new RecyclerView() etc and it'll ask you to import it there. I don't know what classes are required for the JARs you have compiled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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