I try to repair the dependency to google play services in my android project. It already worked but now it is broken. I think this happened in between the Android Studio beta- and release-version.
This is the dependency in the build.gradle file:
dependencies {
compile 'com.google.android.gms:play-services:6.5.87'
}
Android Studio was able to autocomplete the version string: '6.5.87' So I thought it knows how to solve the dependency. But it does not.. This is what I treid:
reinstaled Android Studio (1.0.1) and the Android SDK
used several play-service versions (incl. tried to use '+')
tried to 'gradlew clean' the project
installed almost everything from the Android SDK Manager. (incl. Google Repository and Android Support Repository)
set all environment variables to the correct path
But I still get this error if I try to do a gradle project sync:
Error:Could not find com.google.android.gms:play-services:6.5.87.
Searched in the following locations:
file:/C:/Users/MyName/.m2/repository/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom
file:/C:/Users/MaName/.m2/repository/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar
https://repo1.maven.org/maven2/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom
https://repo1.maven.org/maven2/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar
https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom
https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar
Required by:
code:android:1.0
UPDATE:
Gradle is searching in "file:/C:/Users/MyName/.m2/repository/" but it should use
"file:/C:/Users/MyName/AppData\Local\Android\sdk\extras\google\m2repository" .. I dont know why this is wrong and how to fix it..
UPDATE 2
I fixed it using this workaround:
repositories {
def androidHome = System.getenv("ANDROID_HOME")
maven { url "$androidHome/extras/android/m2repository/" }
maven { url "$androidHome/extras/google/m2repository/"}
}
But I am not happy with it. Does anybody know whats wrong with my gradle?
In Android SDK Manager download the "Google Repository"
Try download the sdk and use this library
compile 'com.google.android.gms:play-services:7.0.0'
After adding jcenter() to reposetories or top level gradle file I fixed the issue
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}
Related
I was following a tutorial to develop icon pack for android and when I imported the project I got several errors and it was solved here - Gradle Version 4.6 - Absolute path are not supported when setting an output file name
After solving that error, the following error poped up.
Could not find com.android.tools.build:aapt2:3.2.0-4818971.
Searched in the following locations:
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
Required by:
project :licensing
I tried to open the URLs and I was able to download JAR (aapt2-3.2.0-4818971-windows.jar) and JSON (aapt2-3.2.0-4818971.pom.json) files from the first 2 URLs. Should I copy these files somewhere? What should I do to solve this error?
Most likely you do not have the Google repository in your project's build.gradle file. Add google() in BOTH locations as shown below:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
I was able to solve the issue by adding google() in both locations:
File -> Project Structure -> Project -> *Now add ", google()" in
Android Plugin Repository
and
Default Library Repository
*
When you upgrade to 4.6 version of gradle. You need following upgrades too. Gradle Plugin Release page.
1. Android Studio 3.+
You need Android Studio version 3.+ to have 4.6 version of gradle. At the time of post latest release was 3.2.1. You can see latest release on this page.
2. Gradle Plugin 3.1.+
You need 3.1.+ gradle plugin for gradle-4.6 support. Check in project level build.gradle.
classpath 'com.android.tools.build:gradle:3.2.1'
At the time of post latest version was 3.2.1. You can see latest release here.
3. Add Google Maven Library
You need to add Google Maven library to project level build.gradle like below code.
buildscript {
repositories {
google()
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
...
}
}
allprojects {
repositories {
google()
...
}
}
see the dependencies of module :licensing and use com.android.tools.build:aapt2:3.2.0 (or even "com.android.tools.build:aapt2:3.2.0:windows") there, which is the final version ...that 4818971 version should ordinary come with an alpha prefix/suffix (the version number seems to be incorrect). maybe adding repository google() might be required, too. ordinary, that dependency should be present; removing that dependency might be another possible option.
For those people who still face exactly the same problem even after adding two google to BOTH positions in relevant gradle file.I would suggest you to check Android Studio -> Preferences -> HTTP Proxy page.
If you find it says some warnings like "...have set JVM proxy to 127.0.0.1".Then you should consider vpn-related issues which depends on your context.
If your desktop is MacOS, then go to Network setting page, advance->proxy tab,uncheck all the checkbox there.
Back to your IDE as following steps: Android Studio->File->Invalidate Caches/Restart.After that,go back to check Android Studio -> Preferences -> HTTP Proxy page again,previous warnings should be gone.Run again.
I solved my issue by upgrading my classpath from
'com.google.gms:google-services:4.0.0
to
'com.google.gms:google-services:4.2.0'
hope this helps
I want to include the material-design library for android into my project, but I'm a bit confused where to find it and how to include it. I downloaded the library from github https://github.com/material-components/material-components-android.
I tried to build it with gradle, but I got the following error, to which I can't seem to find the solution:
> Configure project :catalog
Checking the license for package Android SDK Build-Tools 27.0.3 in /mnt/sda2/android/Sdk/licenses
Warning: License for package Android SDK Build-Tools 27.0.3 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':catalog'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;27.0.3 Android SDK Build-Tools 27.0.3
I have the 'build-tools 27.0.3' installed through the SDK manager. Any hints please on how can I bypass this issue?
As far as I understood, I need to compile the library in the first place, then place it into the /lib folder, and then tell 'Ant' build tool to include this library in order to use it. Is this correct? Maybe there's a place from which I can simply download already pre-compiled lib? I couldn't seem to locate it in the SDK manager. Thank you!
I'm trying to build the project with Gradle now, this is my build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
implementation 'com.google.android.material:material:1.0.0-beta01'
}
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
}
}
but I keep getting an error:
Could not find method implementation() for arguments [com.google.android.material:material:1.0.0-beta01] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Any hints please?
UPDATE
I downloaded android studio, followed the instructions, here's a snippet of my build.gradle:
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
compile "com.android.support:design:27.1.1"
}
but now I'm getting a different error:
Could not find method compile() for arguments [com.android.support:design:25.1.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.
Open Android SDK Manager
I opened the SDK manager, but he Android Support Repository is already installed (rev47). Any hints please? Thanks!
Make sure your compiledSdkVersion is 28
In build.gradle, make sure that the repositories section includes Google's Maven repository google()
i.e.,
add this
allprojects {
repositories {
google()
jcenter()
}
}
Then, add the dependencies.
dependencies {
implementation 'com.google.android.material:material:1.0.0'
}
Then Refactor to AndroidX.
Click on Refactor and then click on Migrate to AndroidX.
Then it will update your app's dependencies and code to use the newly packaged androidx and com.google.android.material libraries.
or
You can use com.android.support:design:28.0.0 dependency if you do not wish to switch to androidx.
Note: You cannot use both com.android.support and com.google.android.material dependencies in your app at the same time.
Hope following things help you :-
**A problem occurred configuring project ':catalog'.Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;27.0.3 Android SDK Build-Tools 27.0.3**
You need to accept the licence first, check the link here for your licence issue :- https://stackoverflow.com/a/41078173/2919483
For adding material design library in Android studio :-
In you build.gradle, add the dependency like:
dependencies {
compile 'com.android.support:design:25.1.0'
}
sync your project and start using that.
I was trying to install new firebase database into my app, but it was failed with next error:
Error:Could not find com.google.firebase:firebase-database:9.2.0. Required
by:
appName:app:unspecified
than i clone official google example frome here and was trying to build database example, but i still get same error...
looks like this is because of some google error. am i right?
in other case, why it happens and how to fix this?
You have to update/install Google Repository, revision 30 (Your android studio latest version).
Instead of adding the project, Just add google services dependency to you root level gradle classpath 'com.google.gms:google-services:3.0.0'
and firebase database dependency to your app level gradle compile 'com.google.firebase:firebase-database:9.2.0'
The part I was missing was in by build.gradle (Project:). Make sure this is there:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
It allows the project to find it in Google's Maven repository.
In my project, I'm trying to use the design support library. I have in my Gradle file:
dependencies {
....
compile 'com.android.support:design'
....
}
And when I try to build this, I get the error:
Normally I would just click Install Repository and sync project, however, this seems to not work anymore. Clicking this does absolutely nothing, even though clicking Open File works fine.
How can I manually install it?
I have the latest Android Support Repository (30.0.0), and Android Support Library (23.2.1) installed.
For me the solution was to add maven in the allprojects section. From the setup document: https://developer.android.com/topic/libraries/support-library/setup.html
in the project level settings.gradle file.
allprojects {
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
}
}
Then double check the document for the latest version.
In the app level of the settings.gradle file add:
dependencies{
compile 'com.android.support:design:26.0.1'
}
And use Gradle to sync the project.
I think it is because you've not specified the version.
compile 'com.android.support:design:23.1.1'
change version to what you have downloaded.
You can go File->Settings->Gradle Look at the "Offline work" inbox,
If it's checked you can uncheck and try to sync again.
I'm trying to add the support libraries to my app by putting this in the dependencies section of build.gradle:
compile 'com.android.support:appcompat-v7:20.0.+'
This works fine in all my libgdx apps except for one of them. It simply cannot find the library. It says:
Error:Could not find any version that matches com.android.support:appcompat-v7:20.0.+.
Searched in the following locations:
file:/C:/Users/MyName/.m2/repository/com/android/support/appcompat-v7/maven-metadata.xml
file:/C:/Users/MyName/.m2/repository/com/android/support/appcompat-v7/
https://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml
https://repo1.maven.org/maven2/com/android/support/appcompat-v7/
https://oss.sonatype.org/content/repositories/snapshots/com/android/support/appcompat-v7/maven-metadata.xml
https://oss.sonatype.org/content/repositories/snapshots/com/android/support/appcompat-v7/
https://oss.sonatype.org/content/repositories/releases/com/android/support/appcompat-v7/maven-metadata.xml
https://oss.sonatype.org/content/repositories/releases/com/android/support/appcompat-v7/
I tried this with the Android support libraries as well, and they have the same issue.
local.properties is pointing to the android sdk just as it is in my other projects.
I see that its searching the Android SDK's local Maven repository for it. But the directory as listed above in the error does not exist. The .m2/repository directory exists with some of my other local stuff, but not the android one. And since this is working fine in my other projects, I'm not sure what could be going on. Perhaps they are checking a different local Maven repository?
I recently installed Maven so I could create my own local repository for use when working on a library project. Maybe I somehow overwrote the original android directory? Doesn't explain why the other old libgdx projects are not failing to find the library though. How can I check where they are searching for it?
Here's the build script (generated by libgdx project generator):
buildscript {
repositories {
jcenter()
maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.4'
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'org.robovm:robovm-gradle-plugin:1.0.0-beta-01'
}
}
Here are relevant parts of build.gradle in top level of project and from the android module:
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
repositories {
mavenLocal()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:6.5.87'
}
Check you Android sdk folder.
You should find this folder under this:
androidSdk/extras/android/m2repository/com/android/support/appcompat-v7/20.0.0
If this folder doesn't exist:
update the SDK Manager and update the Android Repository (the last block).
Also I suggest you using the last releases:
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
Please compile with this
compile 'com.android.support:appcompat-v7:20.0.0'
Instead
compile 'com.android.support:appcompat-v7:20.0.+'
Try adding the mavenCentral repo:
mavenCentral()
to your allprojects
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:6.5.87'
}
Sidenote: the support libraries have been updated (not sure if you need the most recent ones):
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
First check whether you have updated 'Android Support Repository' and 'Android Support Library' in your Android SDK Manager. Once updated, you should be able to build with latest appcompat-v7, at this time 21.0.3.
It would be more tricky for older appcompat-v7 versions. We had the same problem before, we were using appcompat-v7:19.0.+ at the time. It appears that once you update Android Support Repository & Library from Android SDK Manager, which contains the source for your support libraries, there is no going back. Once updated, it will only contain the latest source for support libraries, which means your build will always fail unless you update your build.gradle to point appcompat-v7 to latest version.
I find it surprising that we cannot have multiple versions of appcompat available, like how the SDK manager handles the multiple version of Android SDK build tools.
Sounds support library not installed or not in the right path as Android Studio supposed, so double check:
Check your Android SDK location from: File->project Structure->SDK Location
Then go to SDK Location path to check if \extras\android\support\v7\appcompat available
If not available then start SDK Manager under SDK Location, install both Android Support Library and Android Support Repository under Extras
I eventually fixed this after uninstalling Android Studio and the previous beta version I had, as well as all copies of the Android SDK on my computer. Then I reinstalled a fresh copy of Android Studio with the SDK.
Since none of the project configuration changes I made helped, I think there was possibly some kind of internal configuration in Android Studio that made it point at the wrong Maven repository, possibly the Maven repository in an Android SDK somewhere that was no longer maintained.
I'm glad I didn't reconstruct the project from scratch (to find step-by-step what differed between the problematic project and others that did work). Much faster to reinstall Android Studio.