This question already has answers here:
Android Studio: Plugin with id 'android-library' not found
(10 answers)
Closed 6 years ago.
I am receiving this error, when I try to use a library project in Android Studio. The specific line in build.gradle that gives this error is
apply plugin: 'com.android.library'
I even tried changing it to
apply plugin: 'android-library'
Bu it still doesn't work, instead it says: Error:(7, 0) Plugin with id 'android-library' not found.
I even tried to add:
classpath 'com.android.tools.build:gradle:1.2.3.+'
under dependencies in build.gradle, and still nothing...
Any help?
EDIT: The whole build.gradle
// This buildscript will assemble the MoPub SDK into an AAR.
repositories {
jcenter()
}
apply plugin: 'android-library'
group = 'com.mopub'
description = '''MoPub SDK'''
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
versionCode 25
versionName "3.8.0"
minSdkVersion 9
targetSdkVersion 22
consumerProguardFiles 'proguard.txt'
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src/main/java']
aidl.srcDirs = ['src/main']
renderscript.srcDirs = ['src/main']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard.txt')
}
}
// Note: You will also need a local.properties file to set the location of the SDK in the same
// way that the existing SDK requires, using the sdk.dir property.
// Alternatively, you can set an environment variable called ANDROID_HOME. There is no
// difference between the two methods, you can use the one you prefer.
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3.+'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:support-annotations:22.0.0'
compile 'com.mopub.volley:mopub-volley:1.1.0'
}
// Don't run the Robolectric Unit Tests.
check.dependsOn.remove("test")
check.dependsOn.remove("unitTest")
check.dependsOn.remove("testDebug")
check.dependsOn.remove("unitTestDebug")
You need to write this:
apply plugin: 'com.android.application'
Replace this code in your file too:
buildscript {
repositories {
mavenCentral() // or jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3' // 1.3.0-beta2
}
}
Related
Hello i'm newbie with Android studio , i imported facebook as, and first i got this error Error:(111) Cannot call getBootClasspath() before setTargetInfo() is called. and i followed the right answer here. i.e i changed my depencies from
dependencies {
compile 'com.android.support:support-v4:[21,22)'
compile 'com.parse.bolts:bolts-android:1.1.4'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
and now i'm getting this error
Error:(10, 0) Gradle DSL method not found: 'classpath()'
Possible causes:The project 'FiberTeccpcp' may be using a version of Gradle that does not contain the method.
Gradle settings
The build file may be missing a Gradle plugin.
Apply Gradle plugin
finally this is my build.gradle file
apply plugin: 'com.android.library'
repositories {
mavenCentral()
}
project.group = 'com.facebook.android'
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
}
lintOptions {
abortOnError false
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
apply plugin: 'maven'
apply plugin: 'signing'
......
How can i correct this?
You have to include this part in the buildscript block
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
Should be:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
}
I'm having a problem building APKs in IntelliJ using gradle.Because I import the appcompat library and use the android-library to build it by myself.There are no build errors and output the apk successful.But when you install the apk to phone which has Android 2.3,the action bar is fullscreen.But api >= 14 is totally normal.like this
wrong link:
right link:
But if I use the appcompat library by importing dependency,the apk is normorl.So my problem is why I can’t build appcompat by hand?
Here is my project structure
picture link:
the root project’s build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
}
}
apply plugin: 'com.android.application'
dependencies {
// compile "com.android.support:appcompat-v7:19.1.0"
compile project(":appcompat")
}
ext {
compileSdkVersion = 21
buildToolsVersion = "21.1.2"
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion 8
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
appcompat project’s build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
}
}
apply plugin: 'com.android.library'
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/android-support-v7-appcompat.jar')
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
java.srcDirs = ['src']
}
}
}
settings.build:
include ':appcompat'
Besides,I use gradle 2.2.1,support-v7 19.1.0.
The whole project can download here:
project
Anyone who know this?
Just add to dependencies:
compile 'com.android.support:appcompat-v7:21.0.3'
You shouldn't include jar's of the libraries that are available via repositories.
Note: Don't forget to update the support libraries in SDK Manager.
I am trying to compile (debug) the "HelloWorld" Chromecast Android app supplied by Google on their GitHub page.
After doing numerous updates to the SDK and Android Studio, I am now totally stuck on getting this to run.
I have not changed any code that was supplied.
The current error I get when clicking "debug" is:
"NoSuchMethodError: com.android.builder.model.ProductFlavor.getMinSdkVersion()I: com.android.builder.model.ProductFlavor.getMinSdkVersion()I"
I cannot find any information on this error.
Build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
repositories {
mavenCentral()
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19"
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.android.support:mediarouter-v7:19.0.1'
compile 'com.google.android.gms:play-services:4.2.+'
}
You can try to go in the manifest file and can change the minimum sdk version
Pretty sure you just need to update your Gradle tools version. This line:
classpath 'com.android.tools.build:gradle:0.9.+'
should be:
classpath 'com.android.tools.build:gradle:0.12.+'
Android Studio 0.8+ requires at least 0.12 to properly build your project.
Split your gradle.build:
On the gradle.build of your project leave:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
repositories {
mavenCentral()
}
And on the gradle.build of your module declare:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19"
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.android.support:mediarouter-v7:19.0.1'
compile 'com.google.android.gms:play-services:4.2.+'
}
Put the first code on project gradle configuration and the secod part of code on module gradle configuration file.
I am trying to make a Hello World with AndroidAnnotations and Gradle in IntelliJ IDEA.
(I only have some experience with IntelliJ, all the other stuff is completely new to me.)
I have created a new Gradle: Android Module in IntelliJ IDEA and then edited build.gradle per "Configure your gradle" in the AndroidAnnotations' official guide.
Unfortunatelly, I get this error saying I have no idea what (on line 18: apply plugin: 'android-apt')
Gradle: A problem occurred evaluating project ':Hello'.
> Could not find property 'androidTestCompile' on configuration container.
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
}
}
repositories {
mavenCentral()
mavenLocal() // cache (USER_HOME/.m2 folder)
}
apply plugin: 'android'
apply plugin: 'android-apt' // This is the line of the error
def AAVersion = '3.0.1' // IS THIS OK?
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:18.0.0'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName 'com.hello.app'
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
// resourcePackageName android.defaultConfig.packageName
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
// This is only needed if you project structure doesn't fit the one found here
// http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Project-Structure
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
// java.srcDirs = ['src/main/java', 'build/generated/source/apt/${variant.dirName}']
// resources.srcDirs = ['src/main/resources']
res.srcDirs = ['src/main/res']
// assets.srcDirs = ['src/main/assets']
}
}
}
Version Compatibility.
androidTestCompile was introduced in version 0.9.0 of the Android Gradle plugin (and I was using 0.7.+ here), so 0.9.0 is the minimum one should use with android-apt's newer versions (3.0.1 here).
Also, you might have some more problems with incompatible versions of all these tools.
Here is a table of version compatibility among Android Studio, Android Gradle plugin and Gradle
I'm currently trying to add a library relying on froger_mcs' answer in this post.
Unfortunately, I didn't manage to find build.gradle in library's source files to complete last step:
At the end you have to create another build.gradle file in /libriaries/actionbarsherlock/ directory.
So I added one found in gipi's answer here.
I ended up facing the following problem:
When I run ./gradlew clean it says that gradle version 1.9 is required for the library I'm trying to add. When I change version in gradle-wrapper.properties to 1.9 and run the same task again, it says that gradle version 1.8 is required for my application.
What am I missing?
MyProject/external/TheLibrary/build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
MyProject/MyApp/build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
}
dependencies {
compile project(':external:TheLibrary')
/* other dependencies */
}
MyProject/settings.gradle:
include ':external:TheLibrary', ':MyApp'
Try adding latest version of gradle that is avaliable.
Put in your build.gradle located on root (MyProject in ur case)
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
Plus you don't need to specify gradle for each project. You can put it in your main build.gradle and other libs will read from it. Mine build.gradle looks like that in listing below. And for your case build.gradle will be in root directory MyProject. So you want to edit global build.gradle not the ones that are inside modules (MyApp and TheLibrary). You can delate your claspath to gradles in those modules - make only one globaly.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Put in your gradle wrapper:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
And I think that build tools might be a main problem here. Make every of your lib projects to have the same build tool variant as your main project so, swtich from:
compileSdkVersion 17
buildToolsVersion "17.0.0"
to:
compileSdkVersion 19
buildToolsVersion "19.0.0"
And btw. there is 19.0.3 avaliable.