I have a project where I mix and match regular Android Gradle Plugin:
apply plugin: 'com.android.library'
and Experimental Gradle Plugin as a library:
apply plugin: 'com.android.model.library'
In my overall build.gradle I have the following dependencies:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.android.tools.build:gradle-experimental:0.7.2'
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
And now after upgrade to Android 2.1.3, I get the following error right after the Gradle Sync:
Gradle sync failed: Gradle version 2.10 is required. Current version is >2.14.1. If using the gradle wrapper, try editing the distributionUrl in ?>blah blah blah
At this time In the .idea Android Studio IDE log I see the following error:
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: >Failed to apply plugin [class >'com.android.build.gradle.model.AndroidComponentModelPlugin']
When I fix the gradle-wrapper.properties file I get the following after Gradle Sync:
Error:Minimum supported Gradle version is 2.14.1. Current version is >2.10. If using the gradle wrapper, try editing the distributionUrl in >/Users/development/Desktop/android_msdk/xFAClient/Android/xFA/gradle/wrapp>er/gradle-wrapper.properties to gradle-2.14.1-all.zip
And over and over again...
I have no clue here...
Upgrade gradle experimental to 0.7.3:
classpath 'com.android.tools.build:gradle-experimental:0.7.3'
It allows gradle wrapper 2.14.1 compatibility.
Related
I am trying to build my project in Kotlin and I am getting this error:
Execution failed for task ':app:generateSafeArgsDebug'.
Could not read 'F:\Program Files\Android Projects\CityOnApp\crowdapps-mobile-android\app\build\intermediates\metadata_application_id\debug\application-id.txt' as it does not exist.
and when I added in Settings > Build, Execution, Deployment > Compiler > Command Line Options :
--stacktrace --debug -Pandroid.debug.obsoleteApi=true, then I got :
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
Execution failed for task ':app:generateSafeArgsDebug'.
Could not read 'F:\Program Files\Android Projects\CityOnApp\crowdapps-mobile-android\app\build\intermediates\metadata_application_id\debug\application-id.txt' as it does not exist.
I checked the path and the file does not exist there!
I have the latest version in Kotlin and Android Studio.
What I tried and did not work is :
clean build and rebuild/ build
downgrading the version of Android Studio
deleting the .gradle file from the root directory
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id 'androidx.navigation.safeargs.kotlin' version '2.4.1' apply false
}
To add Safe Args to your project, include the following classpath in your top level build.gradle file:
buildscript {
repositories {
google()
}
dependencies {
def nav_version = "2.3.4"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
You must also apply one of two available plugins.
To generate Java language code suitable for Java or mixed Java and Kotlin modules, add this line to your app or module's build.gradle file:
apply plugin: "androidx.navigation.safeargs"
Alternatively, to generate Kotlin code suitable for Kotlin-only modules add:
apply plugin: "androidx.navigation.safeargs.kotlin"
You must have android.useAndroidX=true in your gradle.properties file as per Migrating to AndroidX.
Source : Official Documentation
Try upgrading/downgrading the gradle plugin.
classpath 'com.android.tools.build:gradle:x.x.x'
Try upgrading/dowgrading gradle wrapper properties
distributionUrl=https\://services.gradle.org/distributions/gradle-x.x.x-bin.zip
Try invalidating caches in Android Studio through the file menu.
Try running Android Studio in admin/sudo.
Check your (git/local)history to see if anything changed that could cause this.
If all else fails, reinstall Android Studio and freshly import your project entirely.
To add safe-args
add this dependencies to build.gradle(project) before plugins{}block on the top
buildscript {
repositories {
google()
}
dependencies {
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.4.2")
}}
this to the build.gradle(Module) file inside plugin{}block
id("androidx.navigation.safeargs.kotlin")
After adding Rebuild the project this will implement the safe-args
I have made an android library and uploaded to Github. (https://github.com/Shekhar23/TxtLogSdk)
Now I want to add to jitpack.io. But I get an error!
How can I upload to jitpack.io?
Build log : https://jitpack.io/com/github/Shekhar23/TxtLogSdk/2.1/build.log
A problem occurred evaluating project ':app'.
Failed to apply plugin [id 'com.android.internal.version-check']
Minimum supported Gradle version is 6.1.1. Current version is 4.8.1. If using the gradle wrapper, try editing the distributionUrl in /home/jitpack/build/gradle/wrapper/gradle-wrapper.properties to gradle-6.1.1-all.zip
Initially I also had this error with Gradle 4.8.1, which was for sure confusing:
Found gradle
Gradle build script
WARNING: gradle/wrapper/gradle-wrapper.jar does not exist! Needs to be committed.
ERROR: Gradle wrapper not found. Please add. Using default gradle to build.
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Welcome to Gradle 4.8.1!
See build.log for details.
What I actually missed, is including ./gradlew and ./gradle/wrapper/gradle-wrapper.jar into the git repository. Yes! You should upload these files to github!
After that you can use the latest gradle version, which is awesome!
Here is the build log:
Found gradle
Gradle build script
Found gradle version: 6.5.
Using gradle wrapper
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Downloading https://services.gradle.org/distributions/gradle-6.5-all.zip
...
------------------------------------------------------------
Gradle 6.5
See build.log for details.
Actually this information is in the official manual https://jitpack.io/docs/ANDROID/ , but the requirement for uploading the gradle-files is not totally clear described.
Comment in this issue was very helpful: https://github.com/jitpack/jitpack.io/issues/2311
P.S. Plugin com.github.dcendents.android-maven should be included to two build.gradle-files as described in the manual.
Did you update your Gradle files?
You should have something similar like the config below:
settings.gradle
include ':app', ':NAME_OF_LIBRARY'
rootProject.name = "NAME_OF_LIBRARY"
build.gradle (module)
Add the plugin, group and version
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.YOURGITHUBNAME'
version = rootProject.ext.versionName
...
build.gradle (project)
Add the github classpath to your dependencies
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
allprojects {
repositories {
google()
jcenter()
...
}
}
ext {
compileSdkVersion = 29
buildToolsVersion = '29.0.2'
versionName = '1.0.0'
...
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Just updated to Android Studio 3.3 RC 2 & gradle tools to 5.1, it started to give the following error,
No such property: dir for class: org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
* What went wrong:
A problem occurred configuring project ':app'.
> groovy.lang.MissingPropertyException: No such property: dir for class: org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Any idea what's the solution to this?
I'm using
com.android.tools.build:gradle:3.4.0-alpha08
The issue with me was related to Jacoco android plugin version 0.1.3
I solved the issue by updating to 0.1.4 and now the issue is solved.
In my case this happened when I upgraded Android Studio to gradle 4.1.0-beta01
The problem was with fabric plugin . I had to replace fabric plugin with firebase-crashlytics-gradle plugin
Project build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0-beta01'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.2"
classpath 'com.google.gms:google-services:4.3.3'
// classpath 'io.fabric.tools:gradle:1.31.2' replaced with below
classpath "com.google.firebase:firebase-crashlytics-gradle:2.2.0"
}
Applevel build.gradle
apply plugin: 'com.google.firebase.crashlytics' //use this instead of fabric
dependencies {
// implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' replace with below
implementation 'com.google.firebase:firebase-crashlytics:17.1.0'
}
The issue for me was the jacoco android plugin integration. Fixed it by removing code related to its integration in the project build.gradle file. Hopes this helps!.
Fixed by downgrading gradle to 4.10.3 and com.android.tools.build:gradle:3.3.0-rc02
I'm using android studio 3.1 and I just configured gradle-wrapper.properties to use gradle-4.5 and it downlowded the file succesfully.
:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
how should I configure classpath in dependencies of build.gradle file?
it was like this when I was using an older version of Gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha09'
}
I changed it to :
dependencies {
classpath 'com.android.tools.build:gradle:4.5'
}
but it didnt work
Don't confuse gradle with android plugin for gradle.
It is the android plugin for gradle and 4.5 doesn't exist.
dependencies {
classpath 'com.android.tools.build:gradle:4.5'
}
It is gradle, and it is enough to use gradle 4.5
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
I have an apparent conflict with firebase 11.8.0 and google-services plugin 3.1.2. The build fails recommending that I use version 11.4.2 of firebase instead.
Relevant extracts of my gradle build files:
Root build.gradle
buildscript {
repositories {
google()
...
}
dependencies {
classpath 'com.google.gms:google-services:3.1.2'
...
}
}
app build.gradle:
apply plugin: 'com.google.gms.google-services'
repositories {
google()
....
}
dependencies {
implementation "com.google.firebase:firebase-core:11.8.0"
....
}
I've correctly generated the firebase app files:
./app/src/debug/google-services.json
./app/src/release/google-services.json
When I build with ./gradlew clean assembleDebug, the build fails with this error:
> Task :app:processDebugGoogleServices FAILED
Found com.google.firebase:firebase-core:11.8.0, but version 11.4.2 is needed for the google-services plugin.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.
The solution is to move this line to the bottom of the app build.gradle file (it shouldn't be at the top):
apply plugin: 'com.google.gms.google-services'
This is specified in the documentation:
https://firebase.google.com/docs/android/setup
Then, in your module Gradle file (usually the app/build.gradle), add
the apply plugin line at the bottom of the file to enable the Gradle
plugin:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:11.8.0'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'