Using a newer Android Gradle plugin in React Native - android

When I try to build our Android React Native app, it generates these warnings related to Gradle:
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
OneSignalPlugin: WARNING: OneSignalPlugin: Downgraded 'com.android.support:33.0.0' -> 28.+ to prevent compile errors! Recommend updating your project's compileSdkVersion!
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 33
This Android Gradle plugin (7.2.1) was tested up to compileSdk = 32
I'm not sure why it's complaining about the compileSdkVersion being updated to 33, as that's exactly what I have specified in my build.gradle file:
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
supportLibVersion = "33.0.0"
castFrameworkVersion = "21.0.0"
kotlinVersion = "1.6.0"
...
However, the more pressing issue is that I'm trying to upgrade the Android Gradle plugin to a newer version. In build.gradle I have:
classpath("com.android.tools.build:gradle:7.0.4")
...and in gradle-wrapper.properties I have:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
I've tried changing build.gradle to use version 7.3.3, however then it fails to find the pom file to download.
> Could not determine the dependencies of null.
> Could not resolve all task dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.3.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.3.3/gradle-7.3.3.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.3.3/gradle-7.3.3.pom
Required by:
project :
> Could not find com.android.tools.build:gradle:7.3.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.3.3/gradle-7.3.3.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.3.3/gradle-7.3.3.pom
Required by:
project : > project :react-native-gradle-plugin
Here is the full build log, in case it helps: https://gist.github.com/justintoth/11b462c7dbe0f51a2e78a62950e2b969

The answer is that there is a difference between the Gradle version (7.4.2 in my case) and the Android Tools Gradle version (7.3.1 in my case.) So in build.gradle I specified:
classpath("com.android.tools.build:gradle:7.3.1")
...and then in gradle-wrapper.properties I have:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
This now "works", although I ran into many other build and runtime errors while upgrading to React Native 0.70.x so I'm still not there yet...

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

How to remove lazyconfigurationusagecontext from my android project?

compileSdkVersion 29
ndkVersion "21.3.6528147"
minSdkVersion 21
targetSdkVersion 29
classpath 'com.android.tools.build:gradle:4.0.0'
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
This is my project details,
I'm getting Gradle sync failed on android studio 4.0.0 due to usage of LazyConfigurationUsageContext,
How I can found LazyConfigurationUsageContext in my project to remove.
I want to use latest gradle version, not give me answer to downgrade gradle version as in this link
Gradle sync failed on android studio 4.0
After a long time I found a solution of it
I removed these lines from my project
apply plugin: 'com.novoda.bintray-release'
classpath 'com.novoda:bintray-release:0.9.1'
after removing these lines project successfully upgraded to latest gradle plugin of android studio

Android studio just installed, gradle errors

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

Android studio - gradle - failed to find target with hash string 'Google Inc.:Glass Development Kit Preview:19'

Failed to sync Gradle Project ‚HelloGlass‘
Error: Cause: failed to find target with hash string 'Google Inc.: Glass Development Kit Preview:19' in D:\Project\Android-SDK
Strangly, this error didn’t appear 3 days ago when I last built the project. I haven’t changed anything or used Android Studio since then.
These are the steps that I’ve tried to solve the issue:
restarted Android Studio and tried to build again
made sure that both gradle and my project use the same path for the Android SDK
made sure that I have the Google Glass Development Kit Installed in the SDK Manager (and all other packages for API 19 as well), also deleted and re-installed it
installed the latest Build Tools via the SDK Manager and consequently changed buildToolsVersion „23.0.1“ to „23.0.2“ in my gradle file
Replaced 'com.android.tools.build:gradle:2.0.0-alpha3' in my top-level gradle file with 'com.android.tools.build:gradle:2.0.0-alpha6' since this is the latest version
in gradle-wrapper.properties changed this line distributionUrl=https://services.gradle.org/distributions/gradle-2.8-all.zip
to this line:
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
and chose „use default gradle wrapper“ in the project options
cleared gradle caches in project/gradle and %HOME%/gradle
tried to build a new Google Glass Project from scratch in Android Studio – same problem
This is the relevant part of my gradle file:
android {
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.helloglass"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
...
And my top-level gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
}
}
I don’t know what else to do. Any help is greatly appreciated!
I haven't found the reason for the problem, but after re-installing both Android Studio and Android SDK I can finally build the project.
Replace
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
with
compileSdkVersion 23
then rebuild the project, hope it will work

Old projects are not building after changing SDK path in Android Studio

Recently, I uninstalled my SDK from location /Users/Shared/Downloads/adt-bundle-mac-x86_64-20130729/sdk and installed in /usr/local/android_sdk/sdk
and the same changes I made in Android Studio Settings
Configure->Project Default->Project Structure->Platform Settings->SDK
Now, The problem is with these changes I can build any new project but when I open my old project It gives me this error:
Gradle 'GPSProvider' project refresh failed:
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.7-bin.zip'.
Build file '/Users/zohrakhan/AndroidStudioProjects/GPSProvider/GPSProvider/build.gradle' line: 9
A problem occurred evaluating project ':GPSProvider'.
A problem occurred evaluating project ':GPSProvider'.
The SDK directory '/Users/Shared/Downloads/adt-bundle-mac-x86_64-20130729/sdk' does not exist.
Please help me to find out the problem.
Edit 1:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
}
Check local.properties file (in /Users/zohrakhan/AndroidStudioProjects/GPSProvider/GPSProviderdirectory). This file may contain:
sdk.dir=/Users/Shared/Downloads/adt-bundle-mac-x86_64-20130729/sdk
So, just replace sdk.dir property.
If it is an Old project and you were using different sdk that time Do the following before import
Delete all the content of .idea directory inside the project directory
Open Studio and import the project and wait until it sync with gradle.
If it gives gradle version related error while sync, update your build.gradle file with whaever version your error message is suggesting.
Now do mentioned below to update your local.propertiesfile
Sync your project with Gradle it will automatically ask if there are any conflicts in your sdk paths in project .
Choose default project sdk to use from dialog.
This is introduced from Android Studio 0.3.7

Categories

Resources