Integrating moPub into Android Studio - java

I'm trying to integrate the moPub sdk into my android studio project, but I haven't been able to get the gradle to sync properly. This question has been asked here before, but none of those solutions have worked for me. I followed these instructions, but got the error messages "Plugin with id org.roboelectric not found" and "Unable to load class org.codehaus.groovy.runtime.typehandling.ShortTypeHandling". To fix this, I modified my app's build.gradle with new classpaths:
// 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:0.12.2'
classpath 'org.robolectric:robolectric-gradle-plugin:1.1.0'
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Unfortunately, I still get the error message "Error:(1, 0) Cause: org/codehaus/groovy/runtime/StringGroovyMethods". I've tried using version 1.0.1 of gradle but nothing changed. I'm not sure where to go from here, so any help would be greatly appreciated.

Read the comment in that build.gradle file.
From this answer https://stackoverflow.com/a/23241888/2278598
<PROJECT_ROOT>\app\build.gradle is specific for app module.
<PROJECT_ROOT>\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules.
You need to put the dependencies you are adding in the <PROJECT_ROOT>\app\build.gradle

You have configured Robolectric correctly in the top level gradle file.
You need to use a later version of gradle to build using the Groovy plugin. I would use classpath 'com.android.tools.build:gradle:1.2.3'

Related

Plugin with id 'com.android.application' not found cannot evaluate the root project [duplicate]

This is my first attempt at Android Studio. I installed 0.8.0 and updated to 0.8.2. As soon as a project is created I get the error message:
Error:(1, 0) Plugin with id 'com.android.application' not found
C:\Users\Bob\AndroidStudioProjects\HelloAgain6\app\build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.bob.helloagain6"
minSdkVersion 15
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'])
}
and C:\Users\Bob\AndroidStudioProjects\HelloAgain6\build.gradle
// 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:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Updated Answer (Dec. 2, 2020)
Latest Gradle: 6.5
Version check:
./gradlew -v
How to update:
Set URL: ./gradlew wrapper --gradle-version=6.5 --distribution-type=all
Update: ./gradlew wrapper
Latest Android Gradle Plugin: 4.1.0
If you add the following code snippet to the top of your build.gradle file. Gradle will update the build tools.
buildscript {
repositories {
google() // For Gradle 4.0+
maven { url 'https://maven.google.com' } // For Gradle < 4.0
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
Read more here: https://developer.android.com/studio/build/index.html and about version compatibility here: https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle and https://dl.google.com/dl/android/maven2/index.html.
Original Answer
I had this same error, you need to make sure your Gradle version is compatible with your Android Gradle Plugin.
The latest version of Gradle is 2.0 but you need to use 1.12 in order to use the Android Gradle Plugin.
This can happen if you miss adding the Top-level build file.
Just add build.gradle to top level.
It should look like this
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.xx.y'
}
}
allprojects {
repositories {
mavenCentral()
}
}
In my case, I download the project from GitHub and the Gradle file was missing. So I just create a new project with success build. Then copy-paste the Gradle missing file. And re-build the project is working for me.
Root-gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:x.x.x'
}
}
allprojects {
repositories {
jcenter()
}
}
Gradle-wrapper.properties file:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-x.x-all.zip
In the project level build.gradle file, I have replaced this line
classpath 'com.android.tools.build:gradle:3.6.3'
with this one
classpath 'com.google.gms:google-services:4.3.3'
After adding both of those lines, and syncing, everything became fine.
Hope this will help someone.
I am writing this not as a solution meant for many, but for some people who may commit a simple mistake like specifying the wrong url for importing projects from SVN. It is intended for those guys :)
This happened to me when I imported the project from SVN -> automatic prompt by Studio to open the project -> It asked for Gradle location -> D:\Software\Android\gradle-2.5 -> Then the error.
The same project in a different SVN branch works fine with the Gradle plugin and Gradle which I have configured in Studio. I tried changing Android Gradle plugin and Gradle to get it working on the erring branch without any success.
Finally, I figured out that it was my following mistake:
I tried importing a specific Application alone instead of importing the application along with dependent library projects.
The url which I used for import initially had the Application porject's name at the end. Once I removed it, and specified the parent directory which contained both application project and its dependent project, everything went smooth :)
I found the problem after one hour struggling with this error message:
I accidentally renamed the root build.gradle to filename in builde.gradle, so Android Studio didn't recognize it anymore.
Renaming it to build.gradle resolved the issue!
I still got the error
Could not find com.android.tools.build:gradle:3.0.0.
Problem: jcenter() did not have the required libs
Solution: add google() as repo
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
}
}
I was using IntelliJ IDEA 13.1.5 and faced with the same problem after I changed versions of Picasso and Retrofit in dependencies in build.gradle file. I tried use many solutions, but without result.
Then I cloned my project from remote git (where I pushed it before changing versions of dependencies) and it worked! After that I just closed current project and imported old project from Gradle file to IntelliJ IDEA again and it worked too! So, I think it was strange bug in intersection of IDEA, Gradle and Android plugin. I hope this information can be useful for IDEA-users or anyone else.
Go to your grade file where you can see this:
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
}
}
And change classpath to this:
buildscript {
repositories {
jcenter()
}
dependencies {
// classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle-experimental:0.7.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
The other answers didn't work for me, I guess something wrong happens between ButterKnife and 3.0.0 alpha5.
However, I found that when I annotated any one sentence, either BUtterKnife or 3.0.0 alpha5, it works normally.
So, you should just avoid the duplication or conflict.
For future reference: For me, this issue was solely caused by the fact that I wasn't running Android Studio as administrator. I had the shortcut on Windows configured to always run as administrator, but after reinstalling Android Studio, the shortcut was replaced, and so it ran without administrator rights. This caused a lot of opaque errors, including the one in this question.
This issue happened when I accidently renamed the line
apply plugin: 'com.android.application'
on file app/build.gradle to some other name. So, I fixed it by changing it to what it was.
[FOR FLUTTER] go to your build Gradle then check if you have three paths
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
I somehow removed the android tools classpath and was getting the error.
This just happened to me using Android Studio 1.3.2, however, since I had just created the project, I deleted it and created it again.
It seems that it had not been properly created by Android Studio the first time, not even the project folders where as expected.
If you run a the module task with android plugin 1.2.3 in module directory , the problem appears. Try this:
../gradlew -b ../build.gradle -c ../settings.gradle :module:xxx
Make sure your two build.gradle and settings.gradle files are in the correct directories as stated in https://developer.android.com/studio/build/index.html
Then open "as existing project" in Visual Studio
Gradle is very finicky about this.
I got this error message after making the following change in my top-level build.gradle to update to the latest version of gradle:
//classpath 'com.android.tools.build:gradle:2.3.2' old
classpath 'com.android.tools.build:gradle:2.3.3' //new
I foolishly made the change while I was connected behind a hostile workplace proxy. The proxy caused the .jar files for the new version of gradle to become corrupt. This can be verified by inspecting the jars to see if they are an unusual size or whether they can be unzipped.
In order to fix the mistake, I connected to my network at home (which is not behind a proxy) and did a refresh dependencies from the Terminal:
./gradlew --refresh-dependencies
This caused the newer version of gradle to be re-downloaded and the error no longer occurs.
Check the spelling, mine was 'com.android.aplication'
This may also happen when you have both settings.gradle and settings.gradle.kts files are present in project root directory (possibly with the same module included). You should only have one of these files.
i had similar problem and i did following things to resolve it.
i referred to https://developer.android.com/studio/build
and copy / pasted these following lines before apply plugin lines
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
}
}
module app build.gradle file
apply plugin: 'com.android.application'
model{
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig.with {
applicationId "com.iamsafe"
minSdkVersion 15
targetSdkVersion 23
}
buildTypes {
debug {
minifyEnabled = false
useProguard = true
proguardFiles.add(file('proguard-rules.txt'))
}
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.2'
compile files('libs/asmack-android-8-0.8.10.jar')
compile files('libs/commons-io-2.0.1.jar')
compile files('libs/httpclient-osgi-4.2.1-sources.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.1.2.jar')
}
project build.gradle
// 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.10'
}
}
allprojects {
repositories {
jcenter()
}
}
In this case of issues check below code
dependencies {
classpath 'com.android.tools.build:gradle:**1.5.0**'
}
and gradle-wrapper.properties inside your project directory check below disctributionUrl:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
If these are not compatible with each other then you end up in this issue.
For com.android.tools.build:gradle:1.5. you need a version at least 2.8 but if you switch to a higher version like com.android.tools.build:gradle:2.1.0 then you need to update your gradle to 2.9 and above this can be done by changing distributionUrl in gradle-wrapper.properties to 2.9 or higher as below
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
If you work on Windows , you must start Android Studio name by Administrator.
It solved my problem
Just make sure you put the http and https proxy correctly when you create the app

Gradle error for build tools for pom and jar files

I wanted to use android gradle 5.5.1 which requires plugin version 3.4.0+ and I'm using plugin version 3.4.2 but when i try to make project i got 4 errors finding .pom and .jar files related to android.tools.build.gradle:3.4.2
I'm freaking and i really need help
Thanks
these is the error
ERROR: Could not find com.android.tools.build:gradle:3.4.2.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.jar
Required by:
project :
Open File
well i tried checking proxy in android studio and it was ok and actualy it download all gradle without any problem. i even used offline gradle but nothing changed ,and i don't know what to do anymore. in repositories i'm using google() ,so don't tell to use google()
here is my gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-5.5.1-all.zip *
and here's my build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
} *
I ended up going in the build.gradle file, and adding google() right above jcenter(), like so.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
}
}
Once I did that, it stopped complaining. I found my answer in the following related question https://stackoverflow.com/a/44071571/11865353
Problem just solved,Because I live in Iran google doesn't allow my ip address to download these files so the solution was to change my ip dns address to something that googlw allows me to download
Solved

Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle

I'm trying to add google play services to my libGDX project in IntelliJ Idea. I've followed the setup guide here: https://developers.google.com/android/guides/setup
which looks pretty straightforward. I just added those lines to my build.gradle in the corresponding section, so things look now like:
project(":android") {
apply plugin: "android"
apply plugin: 'com.android.application'
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile 'com.google.android.gms:play-services:11.2.0'
}
}
Then I try to sync my gradle project in Idea just to get that "Failed to resolve" error.
Well, the setup guide also says "Be sure you update this version number each time Google Play services is updated", but the problem is that it seems nearly impossible to find that version number: my Google Play Services SDK version according to the Android SDK manager is "43", and so far I have been unable to correlate such "11.2.0" or whatever typical version string with the "43" version number. Not that the setup guide says nothing about that.
Anyway, I have tried a lot of things from the plethora of questions related to this to no avail. Specifically, I have to point out that I do have my Android SDK properly updated and I'm sure it is the one it's being used by Idea (I've already triple-checked this...):
I'm using the API level 26, but anyway the other defines do use the very same directory for the Android SDK. Moreover, I do NOT have any other android SDK installed at all in this laptop, so there's no question about Idea being using that one and that one only.
Any ideas are welcome.
I had the issue when I put jcenter() before google() in project level build.gradle. When I changed the order and put google() before jcenter() in build.gradle the problem disappeared
Here is my final build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I just replaced version 11.2.0 with 11.0.0 and then it seemed to work fine, so that had to mean that 11.2.0 wasn't included with the latest Android SDK.
So, after struggling with all the available scattered documentation, I reached this document by pure chance (I guess it is not indexed high enough by Google):
https://developers.google.com/android/guides/releases
I quote from there:
Highlights from the Google Play services 11.2 release. Google Play
services dependencies are now available via maven.google.com
Now, even when that shouldn't necessarily mean that they are not available with the downloaded SDK anymore, it seems that this is actually the case.
Anyway, adding google() to my build.gradle didn't work (not found, undefined, or whatever...), so I used a different approach that I found in this document referenced from the previous one:
https://developer.android.com/studio/build/dependencies.html#google-maven
I modified my build.gradle file adding that line to allprojects/repositories, as in:
allprojects {
...
repositories {
...
maven { url "https://maven.google.com/"}
}
}
And then also in the android section in the same build.gradle file:
project(":android") {
...
dependencies {
...
compile 'com.google.android.gms:play-services-ads:11.2.0'
}
}
Those two lines were enough to make Gradle sync without problems. I didn't need to add any plugins apart from the ones that are already added in my libGDX project by default.
After that, I got a few different errors, but none about Gradle or dependencies. In a brief, JFTR:
First, I had a minSdkVersion of 8. Solved by raising it to 14. I think I could live without supporting all those devices below 14.
Second, I had problems with the dex upper limit of references. I've never faced this problem before, but maybe you've already noticed the solution I used: instead of compiling the whole 'com.google.android.gms:play-services' I used only 'com.google.android.gms:play-services-ads' that's the API I'm actually interested right now. For those other particular cases where a solution like this may not be useful, this document could provide some better insight: https://developer.android.com/studio/build/multidex.html
Third, even after that I got this "jumbo" thing problem described and answered here: https://stackoverflow.com/a/26248495/1160360
And that's it. As of now, everything builds and my game does finally shows those Admob banners.
I've spent hours with this, thought, which makes me wonder if all these building automation systems we are using lately are worth the extra load they add.
I mean, the first time I had to add Admob to an app five years ago or so, I just had to download a .jar file and put it on a directory on my project. It was pretty obvious and the whole process, from googling "how to setup Admob in my android project" to have my app showing an Admob banner took me just a few minutes. I'm gonna leave it here, since this is not the place for such kind of debate.
Nonetheless, I hope my own experience is useful for someone else further.
Add this to your project-level build.gradle file:
repositories {
maven {
url "https://maven.google.com"
}
}
It worked for me
I tried solving this problem for hours after I haven't used Android Studio some time and wasn't aware of the updates.
It is important that google() is the first item that stands in repositories like this:
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
Somehow google() was the second item after jcenter(), so everything was messed up and didn't work. Maybe this helps someone.
Google Play services SDK is inside Google Repository.
Start Intellij IDEA.
On the Tools menu, click Android > SDK Manager.
Update the Android SDK Manager: click SDK Tools, expand Support Repository, select Google Repository, and then click OK.
Current Google Repository version is 57.
After update sync your project.
EDIT
From version 11.2.0, we've to use the google maven repo so add google maven repo link in repositories tag. Check release note from here.
allprojects {
..
repositories {
...
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
}
A more up to date answer:
allprojects {
repositories {
google() // add this
}
}
And don't forget to update gradle to 4.1+ (in gradle-wrapper.properties):
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
source: https://developer.android.com/studio/build/dependencies.html#google-maven
At the latest Google Play Services 15.0.0, it occurs this error when you include entire play service like this
implementation 'com.google.android.gms:play‐services:15.0.0'
Instead, you must specific the detail service like Google Drive
com.google.android.gms:play-services-drive:15.0.0
I have found following solution to replace following code
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
It's work fine for me
In my case I was using version 17.0.1 .It was showing error.
implementation "com.google.android.gms:play-services-location:17.0.1"
After changing version to 17.0.0, it worked
implementation "com.google.android.gms:play-services-location:17.0.0"
Reason might be I was using maps dependency of version 17.0.0 & location version as 17.0.1.It might have thrown error.So,try to maintain consistency in version numbers.
Check you gradle settings, it may be set to Offline Work
I got this error too but for a different reason. It turns out I had made a typo when I tried to specify the version number as a variable:
dependencies {
// ...
implementation "com.google.android.gms:play-services-location:{$playServices}"
// ...
}
I had defined the variable playServices in gradle.properties in my project's root directory:
playServices=15.0.1
The typo was {$playServices} which should have said ${playServices} like this:
dependencies {
// ...
implementation "com.google.android.gms:play-services-location:${playServices}"
// ...
}
That fixed the problem for me.
I had that problem.
And I found this solve.
In Android Studio, Open File menu, and go to Project Structure, In Module app, go to dependencies tab and you can add 'com.google.android.gms:play-services:x.x.x' by clicking on + button.
this is probably about you don't entered correct dependency version.
you can select correct dependency from this:
file>menu>project structure>app>dependencies>+>Library Dependency>select any thing you need > OK
if cannot find your needs you should update your sdk from below way:
tools>android>sdk manager>sdk update>select any thing you need>ok
step 1:
Open android folder
step 2:
open gradlew.bat file
step 3:
Search this (possible line no 74)
#rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
Step 4:
add --offline add the end like
#rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% --offline

How to Configure AdobeCreative SDK for Android gradle build..Correctly

I have just spent hours trying to find out how to configure the AdobeCreative sdk for my android app because I wanted to add photo editing to my application.
The documentation was pretty good but they missed two crucial parts in there documentation which will give plenty of developers headaches. I'm going to answer my question below.
First follow all the documentation from https://creativesdk.adobe.com/docs/android/#/articles/gettingstarted/index.html
However, for your Project gradle.build, the documentation says:
Your Android Studio project contains by default two build.gradle files. In the Project build.gradle file, replace the allprojects block with the following code:
allprojects {
repositories {
jcenter()
maven {
url "${project.rootDir}/creativesdk-repo/release" // Location of the CSDK repo
}
}
}
Be sure to sync your project with the Gradle files after making any edits.
But you should really replace your files with:
allprojects {
apply plugin: 'maven'
repositories {
jcenter()
mavenCentral() //ADD THIS
maven {
url "${project.rootDir}/creativesdk-repo/release"
}
}
}
Notice I added mavenCentral() //ADD THIS.
Without this I received the following errors when doing my gradle build, and I was not able to import any of the classes needed to complete my gradle build:
Error:(38, 13) Failed to resolve: com.adobe.creativesdk.foundation:auth:0.7.329

Error: Could not find com.google.gms:google-services:1.0. when adding google service plugin in build.gradle in android studio

I am integrating OAuth login for Google+ on my android application, following the tutorial.
According to the tutorial, I should add the Google Service plugin by adding
classpath 'com.google.gms:google-services:1.0' dependency to top-level build.gradle in my android project.
However, when I sync the gradle with the changes, I see the error as follows:
Error:Could not find com.google.gms:google-services:1.0.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.jar
https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.pom
https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.jar
In my build.gradle:
// 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:1.2.3'
classpath 'com.google.gms:google-services:1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
It seems that the android studio is not able to find google-services plugin from repositories.
Does anybody have the same issue? Or, am I missing something?
I ran into the same issue today. In the samples they use this line instead:
classpath 'com.google.gms:google-services:1.3.0-beta1'
This works.
For me I had to switch the repository to jcenter(). I was using mavenCentral and getting this error. As soon as I switched to jcenter() it pulled the dependency down.
To do this, open your build.gradle and replace each instance of mavenCentral() with jcenter()
Google updated their guide. Where it was classpath 'com.google.gms:google-services:1.0' now reads classpath 'com.google.gms:google-services:1.3.0-beta1' like joluet suggested.
Google now released the plugin v1.3.0
I was able to solve it using this:
classpath 'com.google.gms:google-services:1.3.0'
I resolved this issue by doing the following things:
In build.gradle (at project level):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}
allprojects {
repositories {
mavenCentral()
}
}
In build.gradle (at module level):
On top added:
apply plugin: 'com.google.gms.google-services'
and in dependecies added:
compile 'com.google.android.gms:play-services-analytics:8.3.0'
Apart from this make sure you have updated the Google Play services and Google repository in the SDK.
As of 25th Nov,2015, google released a newer version.
Try adding:
classpath 'com.google.gms:google-services:2.0.0-alpha1'
And don't forget to add jcenter() repository under buildscript.
Thanks.
I think you forgotten gradle's project level,
From developers page:
Add the dependency to your project-level build.gradle
classpath 'com.google.gms:google-services:1.5.0-beta2'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
Google has updated GCM go check it and for that you have to update your Android Studio too.
I would advise you against doing what you are doing. I did it too (by following Set up a GCM Client App on Android blindly) but ended up with exceeding 65K method limit.
So, you should remove the following lines from your gradle:
apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:1.0'
Now import APIs of Google Plus with simple gradle import:
compile 'com.google.android.gms:play-services-plus:8.1.0'
Adding jcenter repository to project level build.gradle helped in my case:
buildscript {
repositories {
jcenter();
mavenCentral()
}
I was trying to setup firebase for my android app when I faced this problem. Following screenshot should clarify things -
Couple of things I would like to point out -
1. Once you
apply plugin: 'com.google.gms.google-services'
This line should be at the bottom of the app level gradle file. Not sure why but putting at the top did not workout for me.
If you use Android Studio, try to add google service with the IDE.
Right click on folder module.
On left list at Developer Services choose desired service.
Wait for syncing and the IDE will automatically add google dependecies.
add classpath on buildscript
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:1.3.0-beta1'
}
}
You maybe miss this step
Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project. Open the Android Studio Terminal pane:
$ move path-to-download/google-services.json app/
Have fun.
You need to check the current version as in the link below says, by now:
classpath 'com.google.gms:google-services:1.3.0-beta4'
Check this answer:
Update gradle version
We have to look for the last version in my case was:
dependencies {
classpath 'com.google.gms:google-services:1.4.0-beta3'
}
Here you can find a list of the versions.
I got a similar problem while following the instructions for implementing a GCM client in Android Studio, however, the message I got was :
Error: Could not find com.google.gms:google-services:1.3.0-beta1...
Although I never figured out what was wrong, I simply copied my sources, resources, manifest, and keystore into a new Android Studio project. I then edited the auto-generated gradle build files for the new project by manually re-adding my dependencies.
I made sure not to copy over my build files from the old project verbatim (since the source of the error likely lay in them somewhere).
It is not a satisfying solution, but it worked for me and it took little time.
For me adding this under dependencies worked
compile 'com.google.gms:google-services:3.0.0'
Inside the .idea folder exists a workspace.xml file that defines the project's structure. I suggest you to close Android Studio, then delete .idea folder and then import the project again. The .idea would be generated by the IDE again. For me this solution works.
You should just add classpath 'com.google.gms:google-services:1.3.0-beta1' to dependencies of your (Top level build file) the build.gradle that has the (Project:<name of your project). Hope this helps!
I recently updated to Android Studio 2.3 and somehow apply plugin doesn't work.
After that, I tried various ways and then what work is when I commented out app's build.gradle:
apply plugin: 'com.google.gms.google-services'
and then I add this to top-level build.gradle (below classpath 'com.android.tools.build:gradle:2.2.3'):
classpath 'com.google.gms:google-services:3.0.0'
and then it works.

Categories