Kotlin Android Project failed to sync Gradle Project - android

I created an Android project with the newest Android Studio version (v2 Preview 5) and converted it into a kotlin project. Now gradle is not able to sync and build the project, see the screenshot:
I didn't do anything to any build file and I also deleted my entire gradle cache as well as restarting, killing daemons etc. I used the newest kotlin version 1.0.0-beta-4584
As the error message suggest I guess the reason is the kotlin plugin, so does anyone know how to solve this problem?

The kotlin gradle plugin is not compatible with the latest alpha plugin of android (2.0.0-alpha6) or alpha5 for that matter.
Until this is the case, you can use 2.0.0-alpha3 instead.

Related

Data binding with errror dataBindingArtifactOutputDir

I have a weird problem when building my app.
Cannot write to file
'myapp/app/build/intermediates/data-binding/dev/debug/bundle-bin'
specified for property 'dataBindingArtifactOutputDir' as it is a
directory.
It 's weird because when I clean project, I can build app. But when building app the second time, the above error happens. If I want to build app, must clean app.
I also set
dataBinding {
enabled true
}
Thanks for any support!
I really found the problems. I took me 1 day. I updated the gradle plugin and Android Studio to the newest version. And this is the reason why.
The newest gradle build tool is 3.4.1, it use the gradle version 5.1.1. When I downgrade the gradle build tool to 3.1.4 as my old project, and clean build app again error still happens. I think this way did not work but this is problem of Android Studio, it did not change the gradle version in gradle/wrapper/gradle-wrapper.properties. I manually update to old gradle version
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
It works now luckily. Everytime Android Studio updates, the weird problems happens again. Expect everything will work well in the future. :|

"Minimum supported Gradle version is 4.4" error started today; no code changes

Today, multiple developers on my team started seeing this error when they attempt to run any Gradle task.
* Where:
Build file 'C:\dev\src\my_app_name\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Minimum supported Gradle version is 4.4. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in C:\dev\src\my_app_name\gradle\wrapper\gradle-wrapper.properties to gradle-4.4-all.zip
Absolutely no code or config changes were made; Gradle builds just suddenly started to fail. Anyone know why this would happen? My best guess is that a plugin with a dependency on a specific version of Gradle auto-updated itself, but I'm not sure how to figure out which one it is. The line number would suggest that it was the com.application.plugin plugin itself.
I am aware that Android Studio updates often require a corresponding upgrade to Gradle, but nobody on my team updated Android Studio. And, according to the Android-Studio-Gradle version compatibility table, Gradle 4.1 should still work fine with Android Studio 3.0.1, which is what I have been running for some time.
We recently started using Kotlin, and I thought that might be part of the problem, but completely removing everything related to Kotlin didn't help.
I have tried deleting the Gradle caches/ directory, running ./gradlew cleanBuildCache, deleting our project's build/ directories, killing Gradle daemons via ./gradlew --stop, and rebooting -- all to no avail.
I also tried upgrading to Gradle 4.4, but that resulted in a "CIRCULAR REFERENCE" NullPointerException error during DexMergerTransform (separate issue), for reasons that are entirely unclear to me. I'd like to be able to force my environment to NOT take on a Gradle 4.4 dependency right now... but I don't know what suddenly triggered this dependency.
The problem turned out to be that we were using a non-specific version of a plugin. When a change was made to the plugin, the new version was downloaded to our dev environments, and it introduced a dependency on a version of Gradle higher than the one we were using.
In our case, this was the culprit:
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
Downgrading to version 8.5.1 of the Butterknife plugin eliminated the dependency on Gradle 4.4.
You also have the option of linking to a specific pre-release "nightly" version. However, this is less than ideal, since these bits don't remain available for long, and you might want to download a build and keep it in your local lib. For example:
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-20180727.012508-40'
instead of down-grading, one could provide the plugin in version 9.0.0 with the expect version of Gradle, by editing the file gradle/wrapper/gradle-wrapper.properties; for example:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
version 4.5 works stable and might not create the circular reference, alike 4.4 does. and when looking at the issues tracker on GitHub, this Gradle plugin might add more problems, than it would serve any real purpose - because the Android SDK already supports two-way data-binding.
currently the artifacts still list 8.8.1 as the latest version; while a SNAPSHOT is barely stable... that nothing happend there since over a year, hints for that this project might have been abandoned... most likely because of Architecture Components data-binding.

Gradle sync error while building Firebase UI example

I'm trying to build FirebaseUI for Android sample app. Using latest Android studio (2.2.3) and Gradle plugin (2.2.3).
While trying to do Gradle sync I'm receiving following error:
Error:Could not find method baseline() for arguments [/pathToMyProject/FirebaseUI-Android/library/quality/lint-baseline.xml] on object of type com.android.build.gradle.internal.dsl.LintOptions.
Tried the usual stuff (Clean, Invalidate Cashes/Restart) but no luck. Any idea what is wrong here?
Apparently sample code provided by Google doesn't work with latest stable release of Android Studio. This example compiles without problems on latest beta version of AS.

How do you find out what versions of gradle is used in Android Studio

In the build.gradle files, sometimes (I'm not sure when) you'll have to specify what version of gradle is used. The last few updates of Android Studio kept breaking some build files which listed the gradle version in use. I would have to update the gradle version number to fix the build file. I wanted to know if there's a way to figure out what version of gradle is included with Android Studio, instead of having to guess. I haven't been able to find out how to do this through Android Studio.
On Windows you can navigate to C:\Users\<user>\.gradle\wrapper\dists and you can see which gradle versions have been downloaded
If you're using gradle wrapper then you can change (or just check) gradle version number in gradle-wrapper.properties file. In order to do this you have to modify distributionUrl

Project failed to complete the Gradle sync.

Whenever I try to run a gradle sync on my project i keep getting this error:
Failed to refresh Gradle project 'MeetupVersion1.0'
Unable to load class 'org.gradle.plugins.ide.internal.IdeDependenciesExtractor$IdeDependency'.
How do I fix this error? Do I have to import this class or does it have to do with my Android Studio?
This tends to happen when you're trying to use a build file that specifies a version of the Android Gradle plugin that's too new for the given version of Android Studio to handle. I'd suggest updating Android Studio.
If you continue to have problems, amend you question with the version of Android Studio you're using and the contents of your build files.
This is written up in bug https://code.google.com/p/android/issues/detail?id=66325 though the bug report doesn't really have any detail other than a couple reports that people solved it by upgrading.

Categories

Resources