Reputation: 3964
I am unable to sync the Basic Samples project from Google Play Services
. I have tried updating the minsdk
, targetsdk
, compilesdk
versions, updated the project structure and flavors but the project still won't sync
.
This is my error:
Error:Could not find method compile() for arguments [com.android.support:support-v4:24.2.0] on DefaultExternalModuleDependency{group='com.android.support', name='appcompat-v7', version='24.2.0', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency.
Please install the Android Support Repository from the Android SDK Manager.
<a href="openAndroidSdkManager">Open Android SDK Manager</a>
However I installed the latest Android Support Repository (rev 36)
so I assume the issue is something else.
If you want to try and clone the project: https://github.com/playgameservices/android-basic-samples.git
gradle
file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.1'
defaultConfig {
/*
REPLACE THIS VALUE WITH YOUR APPLICATION ID
*/
applicationId "com.google.example.games.replace.me"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile "com.android.support:appcompat-v7:${appcompat_library_version}" compile "com.android.support:support-v4:${support_library_version}" compile project(':libraries:BaseGameUtils')
}
buildscript {
repositories {
jcenter()
}
}
Upvotes: 2
Views: 3737
Reputation: 1110
Make sure you have the following code in your project's build.gradle
:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
My project was missing the Google's Maven Repo URL. Added it and gradle synced like a charm.
Hope it saves someone's time.
Upvotes: 0
Reputation: 3964
Finally got a work around:
I removed this section from the basic samples gradle file
ext {
android_compile_version = 24
android_version = '24.0.1'
android_min_sdk_version = 19
appcompat_library_version = '24.2.0'
support_library_version = '24.2.0'
gms_library_version = '9.4.0'
}
and removed this from the other gradle files:
dependencies {
compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile project(':libraries:BaseGameUtils')
}
and replaced them with the actual values.
dependencies {
compile "com.android.support:appcompat-v7:24.2.0"
compile "com.android.support:support-v4:24.2.0"
compile project(':libraries:BaseGameUtils')
}
Somehow this made all the difference
EDIT
The problem actually was not having end-lines after each dependency! Don't write all your dependencies on the same line
Problem in gradle
file:
dependencies {
compile "com.android.support:appcompat-v7:${appcompat_library_version}" compile "com.android.support:support-v4:${support_library_version}" compile project(':libraries:BaseGameUtils')
}
Solution:
dependencies {
compile "com.android.support:appcompat-v7:24.2.0"
compile "com.android.support:support-v4:24.2.0"
compile project(':libraries:BaseGameUtils')
}
Upvotes: 1
Reputation: 921
The issue is actually a fairly minor one: you don't have end-lines after each dependency.
This
dependencies {
compile "com.android.support:appcompat-v7:${appcompat_library_version}" compile "com.android.support:support-v4:${support_library_version}" compile project(':libraries:BaseGameUtils')
}
should be
dependencies {
compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile project(':libraries:BaseGameUtils')
}
This error is quite common when a plugin on Android Studio edits or modifies the gradle file in any way when the dependency uses a variable instead of a direct reference to the version number. For instance, I've noticed this happen to me when using the Method Counts plugin or even the Firebase plugin.
Upvotes: 8