Android Studio导入第三方库报错处理

来源:互联网 发布:淘宝投诉怎么撤销 编辑:程序博客网 时间:2024/06/05 08:41

   最近开始练习使用Android Studio开发Android应用,之前一直都是在使用eclipse.今天早上在使用studio导入第三方库的时候出现了问题直到现在才处理好,有必要记下来.

    我要导入的库是PullToNextLayout,在GitHub上搜索名字就可以找到.

    当导入成功后报的第一个错是:

       Error:(3, 0) Plugin with id 'com.github.dcendents.android-maven' not found.

    这是因为在PullToNextLayout的build.gradle的plugin是这样的:

        

apply plugin: 'com.android.library'apply plugin: 'com.github.dcendents.android-maven'apply plugin: 'com.jfrog.bintray'

    这个错误需要打开工程(就是最外层)的build.gradle,做如下修改:


dependencies {    //其他的classpath配置    //下面这两行是需要添加的    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'    classpath 'com.github.dcendents:android-maven-plugin:1.2'    // NOTE: Do not place your application dependencies here; they belong    // in the individual module build.gradle files}

     修改完成之后又出现了新的错误:

         Error:Unable to load class 'org.gradle.api.publication.maven.internal.DefaultMavenFactory'.

     我在stackoverflow上看到一种做法可以处理这个报错:

         去设置的 Build, Execution, Deployment > Build Tools > Gradle

         勾选Use default gradle wrapper (Recommended)

    但是在我这里没有作用依然报错.

    然后我又找到一篇贴子,顺利解决了这个问题:

              当你使用的Gradle版本是2.4以上,Android插件版本是1.3.0以上的时候就会出现这个问题,这时候你只需将android-maven-gradle-plugin插件版本改为classpath ‘com.github.dcendents:android-maven-gradle-plugin:1.3’即可
        最后把上面的代码改成:
dependencies {    classpath 'com.android.tools.build:gradle:1.3.0'    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'    // NOTE: Do not place your application dependencies here; they belong    // in the individual module build.gradle files}
    顺利解决问题


0 0
原创粉丝点击