Android Studio: Plugin with id 'android-library' not found

前端 未结 6 2125
北恋
北恋 2020-11-28 02:31

I\'ve been trying to get ActionBarSherlock to work and having some issue. One issue I\'ve come across is the following message when trying to build it:



        
相关标签:
6条回答
  • 2020-11-28 03:13

    Use

    apply plugin: 'com.android.library'
    

    to convert an app module to a library module. More info here: https://developer.android.com/studio/projects/android-library.html

    0 讨论(0)
  • 2020-11-28 03:18

    In later versions, the plugin has changed name to:

    apply plugin: 'com.android.library'
    

    And as already mentioned by some of the other answers, you need the gradle tools in order to use it. Using 3.0.1, you have to use the google repo, not mavenCentral or jcenter:

    buildscript {
        repositories {
            ...
            //In IntelliJ or older versions of Android Studio
            //maven {
            //   url 'https://maven.google.com'
            //}
            google()//in newer versions of Android Studio
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'
        }
    }
    
    0 讨论(0)
  • 2020-11-28 03:19

    Instruct Gradle to download Android plugin from Maven Central repository.

    You do it by pasting the following code at the beginning of the Gradle build file:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.1.1'
        }
    }
    

    Replace version string 1.0.+ with the latest version. Released versions of Gradle plugin can be found in official Maven Repository or on MVNRepository artifact search.

    0 讨论(0)
  • 2020-11-28 03:20

    Use mavenCentral() or jcenter() adding in the build.gradle file the script:

    buildscript {
        repositories {
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:1.5.0'   
        }
    }
    
    0 讨论(0)
  • 2020-11-28 03:23

    Add the below to the build.gradle project module:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.2.3'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    0 讨论(0)
  • 2020-11-28 03:28

    Just for the record (took me quite a while) before Grzegorzs answer worked for me I had to install "android support repository" through the SDK Manager!

    Install it and add the following code above apply plugin: 'android-library' in the build.gradle of actionbarsherlock folder!

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.0.+'
        }
    }
    
    0 讨论(0)
提交回复
热议问题