Android studio是一个非常强大的android程序开发软件。今天就说一下怎样通过AndroidStudio把开源库library项目导入到AndroidStudio的Module中。
1、当然是将library先引入项目中了
New— —Import Module,然后找到library导入项目中来。
2、把Library项目添加到源项目中
打开源项目的build.gradle文件在dependencies 里面添加 compile project(‘:此处填写你想添加的library名称’)。
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile project(':此处填写添加的library')
}
这时build—clean project如果library没有报错,那么恭喜你library导入成功。如果有错误请继续往下看。
3、 Plugin with id ‘com.github.dcendents.android-maven’ not found.问题解决
现在我们打开library的build.gradle文件:
这时我们可以打开下载的原项目下的build.gradle文件
复制这两句代码
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
将这两句代码加入项目中的dependencies中,如下图:
4、修改library报错
现在我们打开library的build.gradle文件,查看dependencies :
这时我们可以打开下载的原项目下的build.gradle文件
根据原项目的build.gradle文件替换为如下内容:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:percent:23.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'konifar:fab-transformation:1.0.0'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
}
这时再build—clean project,如果还有compile ‘konifar:fab-transformation:1.0.0’报错,应该是版本不对,打开Project Structure窗口搜索相应的版本的包添加即可,注意要删除版本不对的包。