Android studio just installed, gradle errors - android

I've just installed Android Studio for windows, I've created a simple android project with a blank activity without modifying it and I got these errors:
C:\Users\Task\AndroidStudioProjects\MyApplication\app\build.gradle
Error:(23, 24) Failed to resolve:
com.android.support.test.espresso:espresso-core:2.0
Error:(26, 13)
Failed to resolve: com.android.support:appcompat-v7:26.+
Gradle Sync Issues
Error:The SDK Build Tools revision (23.0.2) is too low for project
':app'. Minimum required is 25.0.0
I didn't touch anything, every project I create gives me this error, if someone knows what's the problem I would be very grateful for a help, thanks to everyone.

The problems probably related with outdated project template in the Android Studio. You can solve the problems by following the description below.
The first problem:
Error:(23, 24) Failed to resolve:
com.android.support.test.espresso:espresso-core:2.0 Error:(26, 13)
Failed to resolve: com.android.support:appcompat-v7:26.+
is related with support library 26 with google maven. Quoting my answer from https://stackoverflow.com/a/45876864/4758255:
Please be noted that to use support library starting from revision 25.4.0, we need to add google maven. As in the release note says:
Important: The support libraries are now available through Google's
Maven repository. You do not need to download the support repository
from the SDK Manager. For more information, see Support Library Setup.
Read more at Support Library Setup.
Play services and Firebase dependencies since version 11.2.0 are also need google maven. Read Some Updates to Apps Using Google Play services and Google APIs Android August 2017 - version 11.2.0 Release note.
So you need to add the google maven to your root build.gradle like this:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
For Gradle build tools plugin version 3.0.0, you can use google() repository (more at Migrate to Android Plugin for Gradle 3.0.0):
allprojects {
repositories {
jcenter()
google()
}
}
The second problem:
Error:The SDK Build Tools revision (23.0.2) is too low for project
':app'. Minimum required is 25.0.0
means that you need to use minimum build tools version 25. To solve it, first check your root build.gradle. It should be contain something like:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
Second, check your App build.gradle. It should be contain minimum buildToolsVersion 25:
android {
compileSdkVersion 25
buildToolsVersion "25.0.3" // here the builToolsVersion.
defaultConfig {
applicationId "com.example.project"
minSdkVersion 9
targetSdkVersion 25
...
}
..
}

Go to sdk manager >> android sdk >> sdk tools and check everything then click apply
Should be fixed after that

In SDK Manager, you must update SDK Build Tools to the minimum required

Related

Could not resolve all dependencies for configuration ':app debug Runtime Classpath'

I am upgrade my android project gradle 5.4.1-all to 6.5-bin, and upgrade build tools 4.0.0 to 4.1.0, then i am get an error like this
Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Could not create task ':app:minifyReleaseWithR8'.
Cannot query the value of this provider because it has no value available.
upgrading build tools from 4.0.0 to 4.1.0 doesn't sound right to me--
To set the buildToolsVersion (e.g. to '30.0.5') in your build.gradle file, I suggest going to Tools > SDK Manager, then going to the "SDK Tools" tab; here I find the default view misleading, because it shows a certain version of the "Android SDK Platform-Tools" (the one you might have upgraded to) - but then when you tick the option "Show Package Details", you see another version actually installed.
And so I recommend setting the buildToolsVersion to this latter installed version.
Double check the type on what you are assigning to your compileSdkVersion in the build.gradle files.
If you are using a value from gradle.properties you need to parse it into an integer first or you will get this R8 task related crash due to that tasks configuration running triggering further resolution of dependency configurations.
so if you have something like this in your build.gradle:
android {
compileSdkVersion project.targetSdk
...
}
and this in your gradle.properties:
targetSdk=30
you need to parse the integer from the string.
android {
compileSdkVersion Integer.parseInt(project.targetSdk)
...
}
In gradle file, you must have buildtools version, something like:
buildToolsVersion 29.0.3
Make sure you have this version downloaded, the problem is mostly caused by you have no this build tools version.
Download it fron Android Studio sdk manager -> SDK tools tab.
a work around for me in build.gradle app level was to downgrade from:
compileSdkVersion 32
buildToolsVersion '32.0.0'
to :
compileSdkVersion 32
buildToolsVersion '30.0.3'
Noting that :
current config in build.grade project level is:
projectMinSdkVersion = 16
projectTargetSdkVersion = 30

suddenly got error in gradle sync - build tool version 27.0.1 and support version 27.0.1 etc. not found in android studio project

Failed to resolve: com.android.support:support-v13:27.0.1
in my project I am using 25 , but it is showing error for 27.
I opened Android studio project, which was already developed.
Project was built successfully, but after few days suddenly this error came up in gradle sync.
I have installed build tools for 27 and sync with that, but it is still giving same error.
I think it is because of vcs or git used in project, is it possible?
or any other reason ? how to solve it?
Thanks
Add this code in your gradle
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "https://maven.google.com"
}
}
}

Upgrading Gradle Build Tools on older hotfix branches in VCS

I noticed that when loading up your project in Android Studio (currently running 3.1 on Canary Channel), it likes to force you to upgrade Gradle Build Tools and sometimes Gradle itself when it detects it isn't using the latest. The 2 pieces I'm talking about are:
In the root build.gradle:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha03'
}
}
And in gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
Note that I do not specify buildToolsVersion in my Gradle scripts (According to google documentation, this means it tries to use the latest version). I like not specifying it because it's 1 less version I have to continuously change in my Gradle scripts.
For the most part, my question is in regards to best practices. For our software, we tag versions we release to production with the mindset that we might need to go back and hotfix any of those releases. When going back to older hotfixes, should I allow Android Studio to upgrade build tools? Or should I prevent it from doing so (assuming I can, maybe by specifying buildToolsVersion manually)? If the latter case, I don't know how to keep Android Studio from continuously prompting me to upgrade in these cases. Sometimes it seems to fail syncing if I don't upgrade the build tools.
What's the best policy here and what are the functional differences between the two main choices I've outlined?
EDIT:
Here is a screenshot of the prompt I get. It's worded in such a way that it sounds like a build will not be possible unless I upgrade the tools:
And if I click "Update manually" to prevent it from doing so, I get:
I think "Cancel and update manually" in update dialog suits your needs.
If canceled once, you can see the message in status line. (Please see test8)
Also, if you have selected to update, you can manually set it lower again, I think.
Selecting "Update manually" causes build error once, but no error seems to happen if build it again. Please see tests 6-8 below.
Selecting lower gradle plugin version also seems having no problem, as I've tested again from test2 after all tests done.
Updated 2017/12/12
Related resources (to check current version):
Gradle
Gradle - releases
Dec 06, 2017
v4.4
Gradle plugin (>= 3.0.0)
NB: Please see Add Build Dependencies Programmatic access section for details.
Google's maven repo - master index com.android.tools.build
Google's maven repo - build tools group index gradle
3.0.1 or 3.1.0-alpha05
POM file url sample (for stable channel, >= 3.0.0):
NB: These are one of paths that gradle will access to get files
https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom or
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
POM file url sample (for alpha channel, >= 3.0.0):
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0-alpha05/gradle-3.1.0-alpha05.pom
Old gradle plugin (<= 2.3.x)
Maven repo - gradle artifacts
Below here for information:
To see versions:
Android Studio version: Help > About
Gradle plugin version:
build.gradle(Project)
sample: classpath 'com.android.tools.build:gradle:3.1.0-alpha03'
Gradle version:
gradle-wrapper.properties
sample: distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
NB1: Each gradle plugin version has required Gradle version.
See the table in Update Gradle section of this link.
For example: Gradle plugin 3.0.0 requires Gradle 4.1 or higher.
NB2: Some gradle plugin version has required buildToolsVersion, but basically having no relations to it.
For example: Gradle plugin 3.0.0 requires buildToolsVersion 26.0.2 or higher.
NB3: Some gradle plugin version has release notes with "This is a minor update to support Android Studio xxx"
For example: In the section of Gradle plugin 3.0.0
3.0.1 (November 2017)
This is a minor update to support Android Studio 3.0.1
I used same buildToolsVersion (27.0.1) for all tests below.
Android Studio: 2.2.x is 2.2.3 I think.
I used (android-studio-ide-171.4408382-windows) for Android Studio 3.0.x.
,not current one, but I've already downloaded it ago.
Test 1:
Android Studio: 2.2.x
Gradle plugin: 2.3.3
Gradle: 3.3
buildToolsVersion: 27.0.1
buildscript/repositories: jcenter()
build: pass
Test 2:
Android Studio: 3.0.x
Gradle plugin: 2.3.3
Gradle: 3.3
buildToolsVersion: 27.0.1
buildscript/repositories: jcenter()
build: pass
NB: When changing Android Studio version from 2.2.x to 3.0.x for same project, I saw an update dialog, but not the one in the question.
I've selected "Show tomorrow" for it.
Test 3:
Android Studio: 3.0.x
Gradle plugin: 2.3.3
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: jcenter()
build: pass
Test 4:
Android Studio: 3.0.x
Gradle plugin: 3.0.1
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: jcenter()
build: failed
Gradle sync failed: Could not find com.android.tools.build:gradle:3.0.1.
...
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
NB: Have to change repository settings.
Test 5:
Android Studio: 3.0.x
Gradle plugin: 3.0.1
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: google()
build: passed
Test 6:
Android Studio: 3.0.x
Gradle plugin: 3.0.0-alpha9
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: google()
Update dialog is shown.
build: failed after choosing "Cancel and update manually"
In message window:
Error:The project is using an incompatible version of the Android Gradle plugin.
Please update your project to use version 3.0.0.
Search in build.gradle files
NB: This is because gradle plugin 3.0.0 or higher is already released.
Test 7:
Android Studio: 3.0.x
Gradle plugin: 3.1.0-alpha03
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: google()
Update dialog is NOT shown.
build: failed
Event log:
Gradle sync failed: Could not find org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.4-3.
NB1: Have to add kotlin.
NB2: kotlin requires mavenCentral repository.
See Kotlin - Using Gradle
Test 8:
Android Studio: 3.0.x
Gradle plugin: 3.1.0-alpha03
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: google(), mavenCentral()
Update dialog is NOT shown.
build: passed
A message is shown in status line when I click classpath...gradle line in build.config, but no problem.
build.gradle(Project)
buildscript {
repositories {
google()
mavenCentral()
// jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha03'
// classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
// classpath 'com.android.tools.build:gradle:3.0.1'
// classpath 'com.android.tools.build:gradle:3.0.0'
// classpath 'com.android.tools.build:gradle:2.3.3'
// classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0'
}
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
Status line
"A newer version of com.android.tools.build:gradle than 3.1.0-alpha03 is available: 3.1.0-alpha04"

Could not find gradle 3.1

The latest version of gradle is 3.1 enter link description here
but Android Studio is only using 2.2?
enter link description here
This seems likes a huge discrepancy. My configuration:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2'
classpath 'de.felixschulze.gradle:gradle-hockeyapp-plugin:3.2'
classpath 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
}
}
allprojects {
repositories {
jcenter()
}
}
When I try to find gradle 3.1, I get an error that it cannot find it. Same now with 2.2 > Could not find com.android.tools.build:gradle:2.2.
But gradle -v shows
gradle -v
------------------------------------------------------------
Gradle 2.2
how do I resolve this?
You are confusing Gradle with the Android gradle plugin, which generally matches the version of Android Studio. The latest version (at time of writing) is 2.2.2. It is generally set in your project's base build.gradle as you have shown above.
The Gradle wrapper is what you're looking for. You can change the wrapper's settings in your project's gradle/wrapper/gradle-wrapper.properties file.
Change
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip
Again, this is separate from the Android gradle plugin, which simply marries Gradle with Android Studio.
Find all distributions here
Here is the Gradle Version Compatibility for Android Studio
Gradle
refer to link
A problem occurred research project ': sample'.
Failed to apply plugin [id 'com.android.application']
Minimum supported Gradle version is 3.3. Current version is 3.2.1.
The current gradle configuration is also changed to 3.3. The project is running without problems, but can not use the command line (gradle and ./gradlew).
Refer to the online program:
1. Modify gradle-wrapper.properties, and Invalidate Caches / Restart ..., or do not work.
Later in the gradle forum to find a program: Thank you Henry
As new release with the fix not available yet, the former walk-around works fine.
Buildscript {
System.properties ['com.android.build.gradle.overrideVersionCheck'] = 'true'
...
}
. So mark what.
Correction statement : I later found that I installed the sdkman tool,
the tool installed 3.2.1 version, and this should be related (⊙ o ⊙)!
. At the beginning of the show gradle version, will show 3.2.1
version (I am still very depressed, change or show 3.2.1), I have
changed to the environment variable 3.3. I set the gradle environment
variable first, the following is set sdkman environment variable (this
order may also affect). So the final reason is still installed 3.2.1
version.

Android Studio 0.8.0 Error:The SDK Build Tools revision (19.0.3) is too low for project XXX. Minimum required is 19.1.0 [duplicate]

This question already has answers here:
how to force Android Studio 0.6.0 to use SDK Build Tools 19.1.0
(3 answers)
Closed 8 years ago.
After a day of research I still can't figure out how to fix this problem!
I created a build.gradle file in eclipse because we decided to switch to Android Studio (0.8.0)!
However, after the export I got the Error: Error:The SDK Build Tools revision (19.0.3) is too low for project ':XX'. Minimum required is 19.1.0!
I installed the Android-SDK Build-tools from the SDK Manager, i manually configured the build.gradle file and I tried configure it with the "Open Module Settings" but nothing helped!
Here is my build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {}
productFlavors {}
}
dependencies {}
Maybe somebody know what the problem is!
First of all please update Android Studio to 0.8.1. Then you should replace apply plugin: 'android' with apply plugin: 'com.android.application'. Regarding the issue, you need to make sure that you have build tools 20.0.0 installed.

Categories

Resources