Gradle sync fails to get AWS Mobile Client library in Android Studio - android-studio

I have a project loaded in Android Studio 3.0. Gradle sync works fine, and the project builds.
When I add implementation 'com.amazonaws.aws-android-sdk-mobile-client:2.6.+' to my build.gradle (Module:app) file, right next to all the other dependencies that are already part of this fine project, gradle fails to find that dependency. Many of the existing project dependencies are under com.amazonaws.aws-android-sdk-* and are being sync'ed just fine, for e.g. implementation 'com.amazonaws:aws-android-sdk-core:2.6.+' is fine.
So I double check that new project dependency actually exists, browsing http://repo.maven.apache.org/maven2/com/amazonaws/aws-android-sdk-mobile-client shows it exists, I don't see a typo.
Looking at my build.gradle (Project: myProject), I see the following
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
Yet when gradle syncs i get
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.amazonaws.aws-android-sdk-mobile-client:2.6.+:.
Could not resolve com.amazonaws.aws-android-sdk-mobile-client:2.6.+:.
Required by:
project :app
No cached version of com.amazonaws.aws-android-sdk-mobile-client:2.6.+: available for offline mode.`

There is a typo in your dependency.
Use
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.6.+'
instead of
implementation 'com.amazonaws.aws-android-sdk-mobile-client:2.6.+'

uncheck "Offline Work" in Android Studio / File / Settings / Build, Execution, Deployment / Gradle

Related

Sync failed and "Unable to find Gradle tasks to build" after upgrading from Android Studio 2021.3.1 to 2022.1.1

I found several SO posts describing similar issues, but they are outdated and none were found to be helpful in regard to my upgrade to the latest version of Android Studio.
After upgrading my Android Studio from version 2021.3.1 to version 2022.1.1, my attempt to File > Sync Project with Gradle Files results in Sync failed (within less than 200ms).
When I try to Build > Rebuild Project, I get the following error:
Unable to find Gradle tasks to build: [:].
Build mode: REBUILD.
Tests: None.
There is no :app in any of my settings.gradle files.
I did File > Invalidate Caches... (all of them) and restarted AS, but this didn't help.
I also deleted all build folders, but this didn't help.
Any idea how to solve this?
Right-clicking the Sync failed to Reload Gradle Project results in the same failure but it opens now a bar on top of the editor window with the Show Log in Explorer link. When I click it, I indeed find idea.log in C:\Users\WebViewer\AppData\Local\Google\AndroidStudio2022.1\log. I am inspecting it now...
Update:
The first thing I noticed in idea.log is the following exception:
org.gradle.tooling.GradleConnectionException: Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.4-bin.zip'.
...
Caused by: org.gradle.internal.jvm.JavaHomeException: The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Android\Android Studio\jre\bin\java.exe
Thanks to this SO tip, I did mklink /D "jre" "jbr" which all of a sudden revived Android Studio and started to download lots of Gradle related packages.
I still have "Gradle Sync issues" but at least Android Studio prompts me now how to solve them:
but... according to https://developer.android.com/reference/tools/gradle-api Gradle's current release is 7.4.0, why is Android Studio asking for a minimum of 7.5?
Problem solved.
For the benefit of all, I am posting here a summary of what I did to solve it:
When a laconic "Sync failed" is all Android Studio provides, C:\Users\<yourname>\AppData\Local\Google\AndroidStudio2022.1\log\idea.log is key to finding clues to the mystery.
In my case, it was failure to find and run the embedded Java version. So, I did mklink /D "jre" "jbr" which miraculously revived the build process (see https://github.com/flutter/flutter/issues/106674#issuecomment-1381685888).
Under File > Settings > Build Tools > Gradle, this is the Java version that works for me:
I then tried to follow Sync's output to use Gradle 7.5.0. It could not be found on any of the repositories in my top level build.gradle and resulted in chasing my tail... According to https://developer.android.com/reference/tools/gradle-api Gradle's current release is 7.4.0, so I reverted to using it (why didn't it work the first time, I don't know) and here is my working top level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0'
classpath("de.mannodermaus.gradle.plugins:android-junit5:1.8.2.1")
classpath("org.mockito:mockito-inline:4.11.0")
}
}
allprojects {
repositories {
gradlePluginPortal()
mavenCentral()
google()
}
}

Cannot resolve symbol 'Theme' Validates resource references inside Android XML files

After upgrading android studio to 3.1, in old projects I have a problem -
Cannot resolve symbol 'Theme'
Cannot resolve symbol 'Theme' Validates resource references inside Android XML files
I tried to do a lot of things but I still see the same problem.
What I've done: *sync project with gradle files; *invalidate cache and restart; *Bild, Rebild project; *compared gradle version in AS (4.4 - 3.1.0) and in a project (3.1.0) - the same; order of repositories google() jcenter()
and I did many other things but I don't have result(
who knows how to solve?
Close the project from the File menu and open the project again as existing Android Studio project. This worked for me.

Android Studio 3.0 - Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List'

Trying to start a new Kotlin project with Android Studio 3.0 Canary 1 displays this error. Full trace:
Error:Unable to find method
'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List;'.
Possible causes for this unexpected error include:Gradle's
dependency cache may be corrupt (this sometimes occurs after a network
connection timeout.) Re-download dependencies
and sync project (requires network)The state of a Gradle
build process (daemon) may be corrupt. Stopping all Gradle daemons may
solve this problem. Stop Gradle build
processes (requires restart)Your project may be using a
third-party plugin which is not compatible with the other plugins in
the project or the version of Gradle requested by the
project.In the case of corrupt Gradle processes, you can
also try closing the IDE and then killing all Java processes.
I've tried the first two options and the third-party plugins are left as default.
gradle-wrapper.properties
#Thu May 18 08:36:52 BST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.2-3'
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I haven't touched any of these values myself, they're left as default. Creating a non-Kotlin new project does not have this problem.
In my build.gradle changing
ext.kotlin_version = '1.1.2-3'
to
ext.kotlin_version = '1.1.2-4'
fixed this.
You can find the most recent version here.
It worked for me
Using the 8.4.0 version
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
For Java
Just remove
classpath 'me.tatarka:gradle-retrolambda:3.7.0'
downgrade butterknifeversion to 8.4.0
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
Don't forget to remove
apply plugin: 'me.tatarka.retrolambda'
from app level build gradle.
This is a known issue in Android Studio Preview 3.0:
If you see this error, it's possible you have a pre-existing version of the Kotlin plugin that is incompatible with the new Android Plugin for Gradle that's in Android Studio 3.0. The solution is to delete the old Kotlin plugin.
Open your project-level build.gradle file and locate ext.kotlin_version. It should be 1.1.2-4 (or higher). If it shows an older version, you need to delete the old Kotlin plugin so it does not obstruct the version included with Android Studio 3.0.
On Windows, it should be located at
C:\Users\user_name\AndroidStudio_version\config\plugins\Kotlin\
On Mac, look in
~/Library/Application\ Support/AndroidStudio_version/Kotlin/
In my case, the issue was caused because we were applying butterknife-gradle-plugin. Upgrading to 8.8.1 didn't fix the issue, but removing it certainly did.
The build.gradle belongs to the application, so I don't even know why we are using that plugin (I'm new to the project)
Update your kotlin version to the latest:
ext.kotlin_version = '1.1.2-4' //currently it's the latest version
Then you may face some more errors, so before syncing again, make sure that your buildToolsVersion is "26.0.2" or higher.

Project/Gradle files broken after upgrading to Android Studio 2.2

I recently updated Android Studio from version 2.1 to 2.2 and my previously working project has major build errors, centering around a "gradle failed to sync" message I got when opening the project for the first time in version 2.2
It seems that some update occurred to gradle when I did the Studio upgrade to version 2.2, and this update has broken my old project's references (I think). All editing/debugging/simulation features aren't usable within Android Studio when I open this project. What did I do wrong when upgrading, and more importantly how can I fix my broken project and restore full Android Studio functionality while editing this project like I had when running version 2.1.
In the image below you will notice i'm getting a message about a VCS root misconfiguration and all of my toolbar buttons (run, debug, etc) are grayed out.
What can I do to fix this?
I've included my build.gradle file below
// 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.3'
}
}
allprojects {
repositories {
jcenter()
}
}
Same configuration should work.
click on configure VCS(the popup in right side).And to enable Run, Debug etc options, select module(android app module)to run from dropdown option(in left of run option).
For Instant Run to work , update Gradle to 2.2.0-beta3 or higher.

failed to resolve: com.google.android.gms: play-services-games: 6.5+

This project has been working for weeks. Yesterday, Android Studio pulled in some updates, and now gradle cannot find my play-services files. It has literally stopped building with no changes to the project - I didn't think this would happen with a gradle-based project.
gradle sync error
When I click on "Install Repository and sync project", another window opens with the message:
Ignoring unknown package filter 'extra-google-m2repository'Warning: The package filter removed all packages. There is nothing to install.
Please consider trying to update again without a package filter.
Here is my gradle file:
apply plugin: 'android-library'
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services-games:6.5+'
compile 'com.google.android.gms:play-services-plus:6.5+'
compile 'com.google.android.gms:play-services-appstate:6.5+'
}
android {
compileSdkVersion 20
buildToolsVersion '20'
}
Looking in my SDK manager, both "Google Repository" and "Android Support Repository" are installed.
SDK manager screen shot
It is possible that I have two different SDK's, but not sure how to tell if I do, and not sure how to remove the extra one if this is the issue.
Removing the "+" and specifying the specific version allows me to build again. I'm actually using 6.5.87, as 8.4.0 caused some other issue.

Resources