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'
}
}
Related
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'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.
I have successfully imported ActionBarSherlock to my project, and need to import another two libraries: Sliding Layer and Crouton. I know that similar questions have already appeared here before, but I've tried almost everything, each time breaking something in the project in a way that I had to start over.
My project tree looks like:
MyProject/
+ app/
+ libraries/
+ actionbarsherlock/
+ crouton/
+ slidinglayer/
I imported those two libraries as modules (File->Import Module)
My setting.gradle file looks like it should:
include ":libraries:actionbarsherlock", ':Krypto', ':libraries:crouton', ':libraries:slidinglayer'
actionbarsherlock gradle:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
app gradle:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile project(":libraries:actionbarsherlock")
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
slidinglayer gradle:
apply plugin: 'android-library'
dependencies {
compile "com.android.support:support-v4:18.0.0"
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 4
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
In crouton folder there is no gradle.build file. How it should look like? Theres only java files (no resources).
How to set up correctly dependencies in crouton and slidinglayer libraries?
build.gradle for crouton
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
}
}
}
and in your app build.gradle, change
dependencies {
compile project(":libraries:actionbarsherlock")
}
to
dependencies {
compile project(":libraries:actionbarsherlock")
compile project(":libraries:crouton")
compile project(":libraries:slidinglayer")
}
and import again in Android Studio
I don't know how to solve your problem, but when I faced problem of third party library use in Gradle build, I solved by following way.
Following is my structure of project.
GsonDemoProject
GsonDemo
build
libs
android-support-v4.jar
gson.jar
src
main
build.gradle
build.gradle
settings.gradle
I edited my build.gradle file which resides in src directory.
dependencies {
compile files('libs/android-support-v4.jar','libs/gson.jar')
}
I put reference of 3rd party library in dependencies tag like above. In my project libs is directory where libraries are put.
I am having a problem to make my Android application build.
I have one Main application module, and another one that is needed for the google-play-services_lib.
My folder structure is as follows:
ParkingApp
|
|-----> google-play-services_lib (Library Project)
|-----> ParkingApp
|-----> settings.gradle
My settings.gradle file is as follows:
include ':ParkingApp', ':google-play-services_lib'
My ParkingApp has the following build.gradle.
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
compile project(':google-play-services_lib')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
}
}
And the google-play-services_lib has the following build.gradle:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/google-play-services.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
Any help is appreciated!
With the new updates in Android Studio and Gradle, I think a better solution for adding support package and google play services jars is to use the maven repositories instead of adding the library it self, here is how you can add both to any .gradle file, using this way you will no have more problems adding both to dependent projects.
dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
compile 'com.android.support:support-v4:13.0.+'
}
Note: In the new version of Android Studio 0.2.0, you will need also to update the gradle verison to:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
Put google-play-services.jar in MyParkingApp/libs and reference it as a dependency from MyParkingApp/build.gradle.