Building Android Studio project on Jenkins? android.compileSdkVersion is missing - android

I'm trying to set up my first Android project to build on Jenkins.
I'm running Jenkins 1.6.2 with version 1.24 of the Gradle plugin. Running on Windows 7 Professional SP1.
I've installed Android Studio and the Java7 JDK on my build machine, and a checked-out version of the software builds just fine, through Android Studio or when running gradlew.bat from the command line. But I can't get the Invoke Gradle script build task to work, within my Jenkins job.
There is a pair of radio buttons, on the configure project page:
Invoke Gradle
Use Gradle Wrapper
If I select "Invoke Gradle", I'm asked to select a "Gradle Version", which is something I setup in Configure System.
I created a gradle installation with GRADLE_HOME set to "D:\Program Files\Android Studio\gradle\gradle-2.2.1". That gives me a warning that "D:\Program Files\Android Studio\gradle\gradle-2.2.1 is not a directory on the Jenkins master...."
And when I run a build, I get an error "Can't retrieve the Gradle executable".
Which is probably related to the gradle plugin complaining about the directory. But the directory is correct. I've tried it with '/' instead of '\', and it made no difference.
Since that didn't work, I tried the alternative, "Use Gradle Wrapper". There's a checkbox: "From Root Build Script Dir". Whether I check it, or not, I get "java.lang.IllegalArgumentException: android.compileSdkVersion is missing!"
I've set both JAVA_HOME and ANDROID_HOME, so that's not the issue.
Any ideas?
As a followup, I delete the gradle task, and added an Execute Windows batch command task:
SET ANDROID_HOME=d:\Program Files\Android\sdk
SET JAVA_HOME=d:\Program Files\Java\jdk1.7.0_79
.\gradlew.bat clean
When I run that, I still get that error.
But when I run those commands from a command line on the build machine, they work just fine.
What could be different, when running gradlew.bat from Jenkins, than when running it from the command line? The Jenkins service is configured to use the same user as I'm logged in as, when I'm running from the command line. I've tried explicitly setting each and every environment variable I have set in the command line, in the Jenkins task, and I'm still seeing the error.
Any ideas?

Your local.properties file must contain:
sdk.dir="path to your android sdk"

I'm also using jenkins for building my apps and had a similar problem.
I fixed it by executing the gradle wrapper via jenkins without using the jenkins gradle plugin.
cd $WORKSPACE
./gradlew assembleRelease
And if you want lint add a second shell exec with
cd $WORKSPACE
./gradlew lint
Note that these commands are for a linux system but they will work just fine on windows (had a windows build server some time ago and did the same thing)

I met this problem too, but I don't know whether my solution suit for you.
My situation is below, in my project build.gradle file:
apply plugin: 'com.android.library'
apply from: 'maven_push.gradle'
dependencies {
......
}
android {
compileSdkVersion 19
buildToolsVersion "21.1.0"
......
}
When i run: gradle clean build, error message show:
* Where:
Script 'C:\xxxxxx\Project\maven_push.gradle' line: 32
* What went wrong:
A problem occurred evaluating script.
> android.compileSdkVersion is missing!
My solution is change the position of this script apply from: 'maven_push.gradle' to the bottom in build.gradle file, and BUILD SUCCESSFUL!:
apply plugin: 'com.android.library'
dependencies {
......
}
android {
compileSdkVersion 19
buildToolsVersion "21.1.0"
......
}
apply from: 'maven_push.gradle'
I think you should pay attention to the "Where" message in the error command line.

I can't be sure it's gonna solve your issue, but maybe you can consider using the sdk-manager-plugin which downloads and installs the android sdk directly from gradle.
If it works, it probably won't tell you why your current configuration is not working, but at least you won't be stuck anymore.

Related

Deprecated Gradle features were used in this build after setting target api to 31 [duplicate]

I've got a gradle FAILURE:
..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."
Case description:
Attached to the project codebase the next libs:
APP/build.gradle
//(Required) Writing and executing Unit Tests on the JUnit Platform
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
// (Optional) If you need "Parameterized Tests"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.2.0"
// (Optional) If you also have JUnit 4-based tests
testImplementation "junit:junit:4.12"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.2.0"
testImplementation "io.mockk:mockk:1.8.5"
Updated the gradle-wrapper.properties
distributionUrl=https....gradle-4.4-all.zip to 4.7-all
after all of that gradle was built success
created the test calss
#TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestClass {
#Test
internal fun testName() {
Assert.assertEquals(2, 1 + 1)
}
}
ran the test and got the FAILURE message.
ran the Gradle build with a command line argument ./gradlew --warning-mode=all to see what exactly the deprecated features are.
As a result I couldn't build the app and I've got that FAILURE: message.
Run the Gradle build with a command line argument --warning-mode=all to see what exactly the deprecated features are.
It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build.
Adding --stacktrace to that, you will also be able to pinpoint where the warning comes from, if it's triggered by outdated code in one of the plugins and not your build script.
Try this one
cd android && ./gradlew clean && ./gradlew :app:bundleRelease
The process below worked in my case-
First check Gradle Version:
cd android
./gradlew -v
In my case it was 6.5
Go to https://developer.android.com/studio/releases/gradle-plugin and you'll get the plugin version for your gradle version. For gradle version 6.5, the plugin version is 4.1.0
Then go to app/build.gradle and change classpath 'com.android.tools.build:gradle:<plugin_version>
My project was incompatible with Gradle 8.0 .Here's what worked for me:
First I wrote this line of code in the Android Studio terminal:
./gradlew build --warning-mode all
When you do that, you will be shown in the logcat what is found to be deprecated or an issue in your project, for me it was the jcenter() repository that needed to be removed in my settings.gradle file and also I needed to update classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30" in my build.gradle project file.
Once I did these things, my project built perfectly and installed on my emulator
I was getting this error. Turns out it only happened when I completely cleaned the RN caches (quite elaborate process) and then created a release build.
If I cleaned the caches, created a debug build and then a release build, everything worked. Bit worrying but works.
Note: My clean command is...
rm -r android/build ; rm -r android/app/src/release/res ; rm -r android/app/build/intermediates ; watchman watch-del-all ; rm -rf $TMPDIR/react-* ; npm start -- --reset-cache
Important - Answer work only for REACT-NATIVE VS CODE Terminal
In VisualStudio code, you have to run like below then that warning will be omitted.
react-native run-android warning-mode=all
If you run below then you will get the error in terminal
When running react-native run-android --warning-mode all I get error: unknown option --warning-mode'
in my case i updated the build.gradle file and make the classpath to latest version from 3.5.2 to 3.6.3
dependencies {
classpath("com.android.tools.build:gradle:3.6.3")
}
In my case adding multiDexEnabled true in Android/app/build.gradle file compiled the files.
I will look into removing this in the future, as in the documentation it says 'Before configuring your app to enable use of 64K or more method references, you should take steps to reduce the total number of references called by your app code, including methods defined by your app code or included libraries.'
defaultConfig {
applicationId "com.peoplesenergyapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true // <-add this
}
The following solution helped me as I was also getting the same warning.
In your project level gradle file, try to change the gradle version in classpath
classpath "com.android.tools.build:gradle:3.6.0" to
classpath "com.android.tools.build:gradle:4.0.1"
Update your third party dependencies. for example I updated dependency from
implementation 'com.github.ybq:Android-SpinKit:1.1.0' to implementation 'com.github.ybq:Android-SpinKit:1.2.0'. and in my case issue has been solved.
It work for me in this issue in a project of react-native:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
244 actionable tasks: 2 executed, 242 up-to-date
D8: Cannot fit requested classes in a single dex file (# fields: 67296 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
....
I Did this:
Uninstall the app from my device:
The number of method references in a .dex file cannot exceed 64k API 17
Set distributionUrl path in gradle-wrapper-properties files as :
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip
Solution for the issue:
deprecated gradle features were used in this build making it incompatible with gradle 6.0. android studio
This provided solution worked for me.
First change the classpath in dependencies of build.gradle of your project
From: classpath 'com.android.tools.build:gradle:3.3.1'
To: classpath 'com.android.tools.build:gradle:3.6.1'
Then make changes in the gradle-wrapper.properties file this file exists in the Project's gradle>wrapper folder
From: distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
To: distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Then Sync your gradle.
Uninstall the old app from the device/emulator. It worked for me
i'am using react-native and this works for me :
in root of project cd android and gradlew clean
open task manager in windows
on tab 'Details' hit endtask on both java.exe proccess
long story short
> Task :app:installDebug FAILED Fixed by kiling java.exe prossess
Solved this issue by deleting the .gradle folder from /android and again run npm run android, and it solved this error.
Here's a link to the issue: https://github.com/facebook/react-native/issues/28954
I am using react-native if all above didn't work delete Build and .gridle folder inside the Android folder and run again, That solved my problem
Go to gradle/wrapper/gradle-wrapper.properties change the distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip to the release that is needed (or higher).
Then run again cd android && ./gradlew bundleRelease
Finally decided to downgrade the junit 5 to junit 4 and rebuild the testing environment.
On a SpringBoot project using IntelliJ and Gradle, I got the warning "Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0" when running my integration test.
What solved the problem was:
- Going to: File > Settings > Build, Execution, Deployment
- Selecting for "Build and run using": Intellij IDEA (instead of "Gradle")
- Same for "Run tests using"
That did not explain why Gradle is displaying the warning, but that let me perform the test and progress in my work.
I found my disk space is less than 4 GB and can not get the Gradle lib repo
then show
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
just remove tmp and junk files, free up space then try build and resolve problem
In my case deleting the whole android folder from the base directory and allowing it to rebuild all of it on eas build fixed this error for me :)
1)cd android
2) ./gradlew clean
3)./gradlew :app:bundleRelease
then last install npm install command
it is due to incompatibility.
please upgrade classpath("com.android.tools.build:gradle:4.0.1") in build.gradle file under android folder.
Check settings.gradle script and remove jcenter() from that it may be causing the issue as it is deprecated.
You're new settings.gradle file should be
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
plugins {
id 'com.android.application' version '7.1.0-alpha12'
id 'com.android.library' version '7.1.0-alpha12'
id 'org.jetbrains.kotlin.android' version '1.5.21'
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "ComposePlayground"
include ':app'
Take note that ComposePlayground is app name.
I Sloved this problem by updating my gradle-wrapper.properties file. You have to change this line distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip to the lates gradle build which can be found at The Gradle Wrapper.
Hope that helps someone out there :)
After none of the above answers worked for me, I managed to solve this issue by upgrading the Gradle plugin to the latest version and using the JDK 11.
Hope this helps someone!
Try this solution worked for me.
If you have another app with the same name (or package name) on the device: Rename the app or delete it from your device.
For me, the problem was that I ran out of space in my device's internal storage. After deleting a few unnecessary apps, it worked fine.
After hours of searching on the web I used this command:
react-native run-android warning-mode=all
on vs code.
And it turns out that the error have nothing to do with deprecated modules or any gradle error, it was just that my device was full of storage.
I hope it will help someone one day.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. I get error in image fragement [duplicate]

I've got a gradle FAILURE:
..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."
Case description:
Attached to the project codebase the next libs:
APP/build.gradle
//(Required) Writing and executing Unit Tests on the JUnit Platform
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
// (Optional) If you need "Parameterized Tests"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.2.0"
// (Optional) If you also have JUnit 4-based tests
testImplementation "junit:junit:4.12"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.2.0"
testImplementation "io.mockk:mockk:1.8.5"
Updated the gradle-wrapper.properties
distributionUrl=https....gradle-4.4-all.zip to 4.7-all
after all of that gradle was built success
created the test calss
#TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestClass {
#Test
internal fun testName() {
Assert.assertEquals(2, 1 + 1)
}
}
ran the test and got the FAILURE message.
ran the Gradle build with a command line argument ./gradlew --warning-mode=all to see what exactly the deprecated features are.
As a result I couldn't build the app and I've got that FAILURE: message.
Run the Gradle build with a command line argument --warning-mode=all to see what exactly the deprecated features are.
It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build.
Adding --stacktrace to that, you will also be able to pinpoint where the warning comes from, if it's triggered by outdated code in one of the plugins and not your build script.
Try this one
cd android && ./gradlew clean && ./gradlew :app:bundleRelease
The process below worked in my case-
First check Gradle Version:
cd android
./gradlew -v
In my case it was 6.5
Go to https://developer.android.com/studio/releases/gradle-plugin and you'll get the plugin version for your gradle version. For gradle version 6.5, the plugin version is 4.1.0
Then go to app/build.gradle and change classpath 'com.android.tools.build:gradle:<plugin_version>
My project was incompatible with Gradle 8.0 .Here's what worked for me:
First I wrote this line of code in the Android Studio terminal:
./gradlew build --warning-mode all
When you do that, you will be shown in the logcat what is found to be deprecated or an issue in your project, for me it was the jcenter() repository that needed to be removed in my settings.gradle file and also I needed to update classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30" in my build.gradle project file.
Once I did these things, my project built perfectly and installed on my emulator
I was getting this error. Turns out it only happened when I completely cleaned the RN caches (quite elaborate process) and then created a release build.
If I cleaned the caches, created a debug build and then a release build, everything worked. Bit worrying but works.
Note: My clean command is...
rm -r android/build ; rm -r android/app/src/release/res ; rm -r android/app/build/intermediates ; watchman watch-del-all ; rm -rf $TMPDIR/react-* ; npm start -- --reset-cache
Important - Answer work only for REACT-NATIVE VS CODE Terminal
In VisualStudio code, you have to run like below then that warning will be omitted.
react-native run-android warning-mode=all
If you run below then you will get the error in terminal
When running react-native run-android --warning-mode all I get error: unknown option --warning-mode'
in my case i updated the build.gradle file and make the classpath to latest version from 3.5.2 to 3.6.3
dependencies {
classpath("com.android.tools.build:gradle:3.6.3")
}
In my case adding multiDexEnabled true in Android/app/build.gradle file compiled the files.
I will look into removing this in the future, as in the documentation it says 'Before configuring your app to enable use of 64K or more method references, you should take steps to reduce the total number of references called by your app code, including methods defined by your app code or included libraries.'
defaultConfig {
applicationId "com.peoplesenergyapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true // <-add this
}
The following solution helped me as I was also getting the same warning.
In your project level gradle file, try to change the gradle version in classpath
classpath "com.android.tools.build:gradle:3.6.0" to
classpath "com.android.tools.build:gradle:4.0.1"
Update your third party dependencies. for example I updated dependency from
implementation 'com.github.ybq:Android-SpinKit:1.1.0' to implementation 'com.github.ybq:Android-SpinKit:1.2.0'. and in my case issue has been solved.
It work for me in this issue in a project of react-native:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
244 actionable tasks: 2 executed, 242 up-to-date
D8: Cannot fit requested classes in a single dex file (# fields: 67296 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
....
I Did this:
Uninstall the app from my device:
The number of method references in a .dex file cannot exceed 64k API 17
Set distributionUrl path in gradle-wrapper-properties files as :
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip
Solution for the issue:
deprecated gradle features were used in this build making it incompatible with gradle 6.0. android studio
This provided solution worked for me.
First change the classpath in dependencies of build.gradle of your project
From: classpath 'com.android.tools.build:gradle:3.3.1'
To: classpath 'com.android.tools.build:gradle:3.6.1'
Then make changes in the gradle-wrapper.properties file this file exists in the Project's gradle>wrapper folder
From: distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
To: distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Then Sync your gradle.
Uninstall the old app from the device/emulator. It worked for me
i'am using react-native and this works for me :
in root of project cd android and gradlew clean
open task manager in windows
on tab 'Details' hit endtask on both java.exe proccess
long story short
> Task :app:installDebug FAILED Fixed by kiling java.exe prossess
Solved this issue by deleting the .gradle folder from /android and again run npm run android, and it solved this error.
Here's a link to the issue: https://github.com/facebook/react-native/issues/28954
I am using react-native if all above didn't work delete Build and .gridle folder inside the Android folder and run again, That solved my problem
Go to gradle/wrapper/gradle-wrapper.properties change the distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip to the release that is needed (or higher).
Then run again cd android && ./gradlew bundleRelease
Finally decided to downgrade the junit 5 to junit 4 and rebuild the testing environment.
On a SpringBoot project using IntelliJ and Gradle, I got the warning "Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0" when running my integration test.
What solved the problem was:
- Going to: File > Settings > Build, Execution, Deployment
- Selecting for "Build and run using": Intellij IDEA (instead of "Gradle")
- Same for "Run tests using"
That did not explain why Gradle is displaying the warning, but that let me perform the test and progress in my work.
I found my disk space is less than 4 GB and can not get the Gradle lib repo
then show
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
just remove tmp and junk files, free up space then try build and resolve problem
In my case deleting the whole android folder from the base directory and allowing it to rebuild all of it on eas build fixed this error for me :)
1)cd android
2) ./gradlew clean
3)./gradlew :app:bundleRelease
then last install npm install command
it is due to incompatibility.
please upgrade classpath("com.android.tools.build:gradle:4.0.1") in build.gradle file under android folder.
Check settings.gradle script and remove jcenter() from that it may be causing the issue as it is deprecated.
You're new settings.gradle file should be
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
plugins {
id 'com.android.application' version '7.1.0-alpha12'
id 'com.android.library' version '7.1.0-alpha12'
id 'org.jetbrains.kotlin.android' version '1.5.21'
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "ComposePlayground"
include ':app'
Take note that ComposePlayground is app name.
I Sloved this problem by updating my gradle-wrapper.properties file. You have to change this line distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip to the lates gradle build which can be found at The Gradle Wrapper.
Hope that helps someone out there :)
After none of the above answers worked for me, I managed to solve this issue by upgrading the Gradle plugin to the latest version and using the JDK 11.
Hope this helps someone!
Try this solution worked for me.
If you have another app with the same name (or package name) on the device: Rename the app or delete it from your device.
For me, the problem was that I ran out of space in my device's internal storage. After deleting a few unnecessary apps, it worked fine.
After hours of searching on the web I used this command:
react-native run-android warning-mode=all
on vs code.
And it turns out that the error have nothing to do with deprecated modules or any gradle error, it was just that my device was full of storage.
I hope it will help someone one day.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0

I've got a gradle FAILURE:
..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."
Case description:
Attached to the project codebase the next libs:
APP/build.gradle
//(Required) Writing and executing Unit Tests on the JUnit Platform
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
// (Optional) If you need "Parameterized Tests"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.2.0"
// (Optional) If you also have JUnit 4-based tests
testImplementation "junit:junit:4.12"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.2.0"
testImplementation "io.mockk:mockk:1.8.5"
Updated the gradle-wrapper.properties
distributionUrl=https....gradle-4.4-all.zip to 4.7-all
after all of that gradle was built success
created the test calss
#TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestClass {
#Test
internal fun testName() {
Assert.assertEquals(2, 1 + 1)
}
}
ran the test and got the FAILURE message.
ran the Gradle build with a command line argument ./gradlew --warning-mode=all to see what exactly the deprecated features are.
As a result I couldn't build the app and I've got that FAILURE: message.
Run the Gradle build with a command line argument --warning-mode=all to see what exactly the deprecated features are.
It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build.
Adding --stacktrace to that, you will also be able to pinpoint where the warning comes from, if it's triggered by outdated code in one of the plugins and not your build script.
Try this one
cd android && ./gradlew clean && ./gradlew :app:bundleRelease
The process below worked in my case-
First check Gradle Version:
cd android
./gradlew -v
In my case it was 6.5
Go to https://developer.android.com/studio/releases/gradle-plugin and you'll get the plugin version for your gradle version. For gradle version 6.5, the plugin version is 4.1.0
Then go to app/build.gradle and change classpath 'com.android.tools.build:gradle:<plugin_version>
My project was incompatible with Gradle 8.0 .Here's what worked for me:
First I wrote this line of code in the Android Studio terminal:
./gradlew build --warning-mode all
When you do that, you will be shown in the logcat what is found to be deprecated or an issue in your project, for me it was the jcenter() repository that needed to be removed in my settings.gradle file and also I needed to update classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30" in my build.gradle project file.
Once I did these things, my project built perfectly and installed on my emulator
I was getting this error. Turns out it only happened when I completely cleaned the RN caches (quite elaborate process) and then created a release build.
If I cleaned the caches, created a debug build and then a release build, everything worked. Bit worrying but works.
Note: My clean command is...
rm -r android/build ; rm -r android/app/src/release/res ; rm -r android/app/build/intermediates ; watchman watch-del-all ; rm -rf $TMPDIR/react-* ; npm start -- --reset-cache
Important - Answer work only for REACT-NATIVE VS CODE Terminal
In VisualStudio code, you have to run like below then that warning will be omitted.
react-native run-android warning-mode=all
If you run below then you will get the error in terminal
When running react-native run-android --warning-mode all I get error: unknown option --warning-mode'
in my case i updated the build.gradle file and make the classpath to latest version from 3.5.2 to 3.6.3
dependencies {
classpath("com.android.tools.build:gradle:3.6.3")
}
In my case adding multiDexEnabled true in Android/app/build.gradle file compiled the files.
I will look into removing this in the future, as in the documentation it says 'Before configuring your app to enable use of 64K or more method references, you should take steps to reduce the total number of references called by your app code, including methods defined by your app code or included libraries.'
defaultConfig {
applicationId "com.peoplesenergyapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true // <-add this
}
The following solution helped me as I was also getting the same warning.
In your project level gradle file, try to change the gradle version in classpath
classpath "com.android.tools.build:gradle:3.6.0" to
classpath "com.android.tools.build:gradle:4.0.1"
Update your third party dependencies. for example I updated dependency from
implementation 'com.github.ybq:Android-SpinKit:1.1.0' to implementation 'com.github.ybq:Android-SpinKit:1.2.0'. and in my case issue has been solved.
It work for me in this issue in a project of react-native:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
244 actionable tasks: 2 executed, 242 up-to-date
D8: Cannot fit requested classes in a single dex file (# fields: 67296 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
....
I Did this:
Uninstall the app from my device:
The number of method references in a .dex file cannot exceed 64k API 17
Set distributionUrl path in gradle-wrapper-properties files as :
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip
Solution for the issue:
deprecated gradle features were used in this build making it incompatible with gradle 6.0. android studio
This provided solution worked for me.
First change the classpath in dependencies of build.gradle of your project
From: classpath 'com.android.tools.build:gradle:3.3.1'
To: classpath 'com.android.tools.build:gradle:3.6.1'
Then make changes in the gradle-wrapper.properties file this file exists in the Project's gradle>wrapper folder
From: distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
To: distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Then Sync your gradle.
Uninstall the old app from the device/emulator. It worked for me
i'am using react-native and this works for me :
in root of project cd android and gradlew clean
open task manager in windows
on tab 'Details' hit endtask on both java.exe proccess
long story short
> Task :app:installDebug FAILED Fixed by kiling java.exe prossess
Solved this issue by deleting the .gradle folder from /android and again run npm run android, and it solved this error.
Here's a link to the issue: https://github.com/facebook/react-native/issues/28954
I am using react-native if all above didn't work delete Build and .gridle folder inside the Android folder and run again, That solved my problem
Go to gradle/wrapper/gradle-wrapper.properties change the distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip to the release that is needed (or higher).
Then run again cd android && ./gradlew bundleRelease
Finally decided to downgrade the junit 5 to junit 4 and rebuild the testing environment.
On a SpringBoot project using IntelliJ and Gradle, I got the warning "Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0" when running my integration test.
What solved the problem was:
- Going to: File > Settings > Build, Execution, Deployment
- Selecting for "Build and run using": Intellij IDEA (instead of "Gradle")
- Same for "Run tests using"
That did not explain why Gradle is displaying the warning, but that let me perform the test and progress in my work.
I found my disk space is less than 4 GB and can not get the Gradle lib repo
then show
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
just remove tmp and junk files, free up space then try build and resolve problem
In my case deleting the whole android folder from the base directory and allowing it to rebuild all of it on eas build fixed this error for me :)
1)cd android
2) ./gradlew clean
3)./gradlew :app:bundleRelease
then last install npm install command
it is due to incompatibility.
please upgrade classpath("com.android.tools.build:gradle:4.0.1") in build.gradle file under android folder.
Check settings.gradle script and remove jcenter() from that it may be causing the issue as it is deprecated.
You're new settings.gradle file should be
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
plugins {
id 'com.android.application' version '7.1.0-alpha12'
id 'com.android.library' version '7.1.0-alpha12'
id 'org.jetbrains.kotlin.android' version '1.5.21'
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "ComposePlayground"
include ':app'
Take note that ComposePlayground is app name.
I Sloved this problem by updating my gradle-wrapper.properties file. You have to change this line distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip to the lates gradle build which can be found at The Gradle Wrapper.
Hope that helps someone out there :)
After none of the above answers worked for me, I managed to solve this issue by upgrading the Gradle plugin to the latest version and using the JDK 11.
Hope this helps someone!
Try this solution worked for me.
If you have another app with the same name (or package name) on the device: Rename the app or delete it from your device.
For me, the problem was that I ran out of space in my device's internal storage. After deleting a few unnecessary apps, it worked fine.
After hours of searching on the web I used this command:
react-native run-android warning-mode=all
on vs code.
And it turns out that the error have nothing to do with deprecated modules or any gradle error, it was just that my device was full of storage.
I hope it will help someone one day.

Configure Bamboo for Android Gradle based Project

I am trying to setup Bamboo for my Gradle build system based Android Project.
I have done the following setup on Bamboo.I'm done with rest of all setup upto project repository path.
I want to run the following tasks using gradlew for android
clean assembleDebug LintDebug
For that I have created new task called Gradle Wrapper.
Below is the Gradle Wrapper Configuration
When I am executing gradle wrapper task, I am getting the following error.
Caused by: java.lang.IllegalStateException: Cannot find executable 'D:\AndroidDemo\gradle-2.10\bin\gradlew.bat'
Note :- Standalone Gradle is working fine on local machine with all the tasks(clean assembleDebug LintDebug)
Gradle_Home = D:\AndroidDemo\gradle-2.10\bin(Local machine)
Can anyone suggest a solution for the same?
I also had some initial difficulties to set up Bamboo to build an Android project using Gradle.
First of all, make sure that you have the Gradle wrapper (gradlew) in your repo. (Seemingly that's the situation in your case). It seems to me, however the Gradle wrapper ignores the system default Gradle distribution (set by the GRADLE_HOME env var), and always downloads a Gradle version mandated by the Android Build tools.
Also make sure, that the Android SDK root environment variable (ANDROID_HOME or ANDROID_SDK_ROOT) is pointing to the SDK's root directory (e.g. $ export ANDROID_HOME="/opt/android-sdk/")[1].
Restart Bamboo after applying the environment variable changes.
In Bamboo, in the build tasks lists, add a new Script task. The interpreter should be '/bin/sh or cmd.exe', the script location should be 'inline', and the script body should contain the call for the parametrized Gradle wrapper, e.g.
gradlew clean build
Point the working subdirectory to the Gradle wrapper's relative location (to the repo root), if necessary.
[Sample Bamboo Android Gradle build script]
After these steps, Bamboo should execute the Gradle wrapper, which in fact should perform the actual build steps.

Android Studio how to run gradle sync manually?

I'm debugging Gradle issues in Android Studio and see references to "Run gradle sync", but I'm not sure how to run this command.
How do I run "Gradle sync" from Android studio or Mac terminal?
Android studio should have this button in the toolbar marked "Sync project with Gradle Files"
EDIT: I don't know when it was changed but it now looks like this:
EDIT: This is what it looks like on 3.3.1
OR by going to File -> Sync Project with Gradle Files from the menubar.
WARNING: --recompile-scripts command has been deprecated since gradle's version 5.0.
To check your gradle version, run gradle -v.
./gradlew --recompile-scripts
it will do a sync without building anything.
Alternatively, with command line in your root project
./gradlew build
It will sync and build your app, and take longer than just a Gradle sync
To see all available gradle task, use ./gradlew tasks
In Android Studio 3.3 it is here:
According to the answer https://stackoverflow.com/a/49576954/2914140 in Android Studio 3.1 it is here:
This command is moved to File > Sync Project with Gradle Files.
Keyboard shortcut lovers can add a shortcut for running gradle sync manually by going to File -> Settings -> Keymap -> Plugins -> Android Support -> Sync Project with gradle files (Right click on it to add keyboard shortcut) -> Apply -> OK and you are done. Choose any convenient key as your gradle sync shortcut which doesnot conflict with any other shortcut key, (I have choosen Shift + 5 as my gradle sync key), so next when you want to run gradle sync manually just press this keyboard shortcut key.
I presume it is referring to Tools > Android > "Sync Project with Gradle Files" from the Android Studio main menu.
gradle --recompile-scripts
seems to do a sync without building anything.
you can enable automatic building by
gradle --recompile-scripts --continuous
Please refer the docs for more info:
https://docs.gradle.org/current/userguide/gradle_command_line.html
Shortcut (Ubuntu, Windows):
Ctrl + F5
Will sync the project with Gradle files.
I think ./gradlew tasks is same with Android studio sync. Why? I will explain it.
I meet a problem when I test jacoco coverage report. When I run ./gradlew clean :Test:testDebugUnitTest in command line directly , error appear.
Error opening zip file or JAR manifest missing : build/tmp/expandedArchives/org.jacoco.agent-0.8.2.jar_5bdiis3s7lm1rcnv0gawjjfxc/jacocoagent.jar
However, if I click android studio sync firstly , it runs OK. Because the build/../jacocoagent.jar appear naturally.
I dont know why, maybe there is bug in jacoco plugin. Unit I find running .gradlew tasks makes the jar appear as well. So I can get the same result in gralde script.
Besides, gradle --recompile-scripts does not work for the problem.
I have a trouble may proof gradlew clean is not equal to ADT build clean. And Now I am struggling to get it fixed.
Here is what I got:
I set a configProductID=11111 from my gradle.properties, from my build.gradle, I add
resValue "string", "ProductID", configProductID
If I do a build clean from ADT, the resource R.string.ProductID can be generated. Then I can do bellow command successfully.
gradlew assembleDebug
But, as I am trying to setup build server, I don't want help from ADT IDE, so I need to avoid using ADT build clean. Here comes my problem.
Now I change my resource name from "ProductID" to "myProductID", I do:
gradlew clean
I get error
PS D:\work\wctposdemo> .\gradlew.bat clean
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\work\wctposdemo\app\build.gradle'
* What went wrong:
Could not compile build file 'D:\work\wctposdemo\app\build.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 57
If I try with:
.\gradlew.bat --recompile-scripts
I just get error of
Unknown command-line option '--recompile-scripts'.
Anyone wants to use command line to sync projects with gradle files, please note:
Since Gradle 5.0,
The --recompile-scripts command-line option has been removed.
https://docs.gradle.org/5.0/userguide/upgrading_version_4.html#potential_breaking_changes
https://docs.gradle.org/current/userguide/command_line_interface.html
https://github.com/gradle/gradle/issues/1425
From terminal:
gradle prepareKotlinBuildScriptModel
NOTE: you can see what android studio is doing by inspecting the "Build" tab. There will be difference windows inside there. One should be "Sync"

Categories

Resources