android studio add libs and .jar

1.add libs directory.step:
a. select module in project view
这里写图片描述
b. right key of mouse new->Directory and give name “libs”
then,it looks like this
这里写图片描述
2.copy .jar to this directory
for example:use linux cmd :cd xxx/app//libs;cp xx.jar ./libs
then,it looks like this
这里写图片描述
3.modify the build.gradle of the module

android {
...
sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
    repositories {
        flatDir {
            dirs 'libs'
        }
    }
 }
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    ...
    implementation files('libs/achartengine-1.0.0.jar')
}
...

猜你喜欢

转载自blog.csdn.net/niubichen16/article/details/82422195