How to import a project in Android Studio - android

I get this error during gradle build when importing a project in android studio o.8.14
Gradle DSL method not found: 'android()''
I know the error has something to do with the gradle files but I don't know the way forward or where exactly to start.
The top level build.gradle file looks like this
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:+'
}
And the module build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.shimba.android.events"
minSdkVersion 9
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile project(':universalImageLoaderLibrary2')
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v4:20.+'
}
Where am I going wrong?

Related

no matter what I do I can't add realm to my project

this is my gradle file
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.nuku.mc.populate_recyclerview"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
incremental false
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath "io.realm:realm-gradle-plugin:0.88.3"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0'
compile 'com.mcxiaoke.volley:library:1.0.17'
compile 'com.github.bumptech.glide:glide:3.5.2'
}
}
1)I tried to compile
2) I tried removing this line ->
classpath 'com.android.tools.build:gradle:2.0.0'
3) I tried without the build script{...} and added classpath with my other dependencies but it's still saying:
and my gradle is saying:
Error(2,0) plugin with id 'realm-andoid' not found
Add the following line to your app module build.gradle file.
apply plugin: 'realm-android'
And and these lines to the project level build.gradle file.
dependencies {
classpath "io.realm:realm-gradle-plugin:1.1.0"
}
But it seems you add all of them in your app module build.gradle file.

Error(3,0) Gradle DSL method not found: 'buildToolsVersion()'

Please I am a beginner in Android development.
I just tried to run my first code in line with the tutorial I am using to learn.
I got this error:
Gradle DSL method not found: 'buildToolsVersion()'
This is my build.gradle(Project:HappyBirthday)
// 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.1.0'
// 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
}
And this is my build.gradle(Module:app)
apply plugin: 'com.android.application'
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.android.happybirthday"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
You seem to be missing the android closure and your compileSdkVersion line. Change your second file to look like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.android.happybirthday"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}

'Gradle sync failed: Gradle DSL method not found: 'minSdkVersdion()'

Gradle sync failed: Gradle DSL method not found: 'minSdkVersdion(). I am using latest version of Android studio 2.0.
Here is my updated gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId 'com.gkhindi'
minSdkVersdion 16
targetSdkVersion 23
versionCode 1
versionName '1.0.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/StartAppInApp-3.1.0.jar')
compile files('libs/Shutterbug-1.0.0.jar')
compile files('libs/Parse-1.11.0.jar')
compile files('libs/bolts-tasks-1.3.0.jar')
// compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-games:8.4.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
}
android {
useLibrary 'org.apache.http.legacy'
}
This is my final gradle. When i syn the gradle then I am receiving the error is 'Gradle sync failed: Gradle DSL method not found: 'minSdkVersdion()'.
There is a typo in your build.gradle
minSdkVersdion 16
instead of
minSdkVersion 16

Referencing SpotifyWebApi in AndroidStudio

I'm trying to reference SpotifyWebApi in AndroidStudio. I'm using the instructions here
https://github.com/kaaes/spotify-web-api-android/blob/master/README.md
However I get the error
Error:Failed to resolve: :spotify-web-api-android-0.1.0:
when I try to build.
How can I fix this? I have AndroidStudio 1.2.2
Here's my Module:app build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "app.com.example.android.spotifystreamerstage1"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'spotify-web-api-android-0.1.0', ext:'aar')
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
// Other dependencies your app might use
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
spotify-web-api-android is not included maven central repository. the doc of the link has wrong info. I don't know why..
Alternatively I have found this link and next codes.
repositories {
maven {
url "https://github.com/z0lope0z/raws/raw/master"
}
mavenCentral()
}
dependencies {
compile 'kaaes.spotify.webapi.android:spotify-web-api-android:0.1.0'
}

Why can't I add support library in Android Studio?

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.0.+'
compile 'com.android.support:support-v4:19.0.+'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile project(':library:SlidingMenu:library')
compile project(':library:Android-ViewPagerIndicator:library')
compile fileTree(dir: 'libs', include: ['*.jar'])
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Event Log
Failed to refresh Gradle project 'My Application' Could not find method compile() for arguments [com.android.support:appcompat-v7:19.0.+] on project ':app'. Please install the Android Support Repository from the Android SDK Manager.

Categories

Resources