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. :|
Related
I am trying to move some business logic from my iOS apps to KMM. I have already made some job when suddenly started having problems with studio. It was not building, there were weird metaspace errors, etc. I was beating around my project for several hours and days to be honest - no result. I decided to completely uninstall studio and all its dependent files.
After that I'm not even able to properly build an empty KMM project. Simple Android projects work just fine. Problems occur only with KMM. When I have created a project for the first time, it has loaded successfully, downloaded all the dependencies and synced. I was able to see "Android" project structure. I tried to build it via ./gradlew build - error. There was no complete description, only the name of the failed task - compile kotlin to ios arm64. An error in a completely new project. I tried rebuilding project - no luck. So I restarted studio and here the second part of magic begins.
From this moment whenever I open a new or existing KMM project, it starts syncing and stucks. I can't open project structure for example, because sync is in progress, I can't add dependencies, because sync is in progress. But I can build it via ./gradlew build and it builds! Well, I tried some more commands, like ./gradlew -refresh-dependencies etc. It was building successfully. And then at some point all the code became red. Below you can see all the colors of Android Studio at the same time:
In the terminal you can see that it was built successfully. In the lower right corner you can see that it doesn't allow to go to the project structure because of sync in progress. And the most beautiful are all that unresolved symbols.
I believe I have tried the most of these Android Studio things:
Invalidate cache & restart
Just restart
Rebuild project
./gradlew clean build
Deleting ~/.gradle and ./gradle and rebuild
Restarting the laptop
Updating all plugins
etc.
Guys, do you have any ideas how can I make studio just work with KMM? And then how should I make it keep working? As I've already said, the problem is not studio specific, it is KMM specific, because regular android projects build just fine.
Android Studio 4.1.2
Mac OS Big Sur 11.2
Kotlin 1.4.30-release-Studio4.1-1
I guess you have encounterd this issue.
Actually I didn't figure how to fix it out, but you can try AS 4.2-beta as this issue seems not be present in this AS build.
The same happend to me and I switch to AS 4.2 beta.
The only difference between you and me is Kotlin version: I have 1.4.21
UPDATE
It turned out that I had a misconfiguration between KMM plugin e Kolin version.
AS 4.1 should work correctly only with KMM plugin 0.2.0 and Kotlin 1.4.20, I had Kotlin 1.4.30 instead. Switching back to Kotlin 1.4.20 fixed this.
I was running Android Studio 3.5. My code was compiling and installing onto the emulator just fine.
I updated Android Studio to 3.6.1.
The only parts of my code that change are:
gradle updated from 5.4.1 to 5.6.4
Android gradle build tools updated from 3.5.3 to 3.6.1
Now I get the following error when trying to run the debug flavor (release works fine) of my app
Installation did not succeed.
The application could not be installed:
INSTALL_FAILED_INVALID_APK The APKs are invalid.
I have tried to delete the emulator and make a new one. I have tried clean, rebuild, invalidate cache. Nothing seems to be working.
Found the solution to my own problem. Note to others, make sure your libraries and classpaths are always up to date. I had a classpath for firebase plugins that was not up to date. When applying the new gradle, this problem occurred. After updating the classpath everything installed smoothly again
This problem is usually caused due to a difference in the mainfest package name and the Gradle applicationId.
First, check that they both are same.
Then, check that there are no spaces in the package name and it has proper (.) separators.
Also, check that it has no other separators (- or,) other than (.).
This should work for you.
Do post your manifest and Gradle configuration file.
I upgraded the studio to 3.1.2 version lately. After that facing few issues, one of which is this :
Even though all imports are written correctly, the files are said not to be found and I get the class names in red saying "Cannot resolve symbol".
But when I try to run the project it runs perfectly. I tried to invalidate cache and restart, clean project, rebuild project, also tried restarting the PC but no solution.
You have to update your Kotlin library version and check some other version of library it might be not compatible with new android studio version and also check gradle version.
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.
I have updated SDK and I am using Android studio 2.0(preview). So I think all things are enough updated. For me and for my newly created projects all things work fine. But When Ever I download the code from github I always gets error of gradle versions.
So It is kind of annoying. Well I admire a lot of things are already fixed by gradle while importing that github project . But once the gradle version error occur its some times gets hard to know the exact reason. And honestly I know things about gradle quite enough , but I always get it solved by hit and trial method. So I have many confusions which I am posting below as a questions
How to know what is new gradle version is going on.
How to know which things are now forbidden in the new version of gradle
How to know which support dependencies will work with new gradle version
How to know which version of build tools will perfectly match to gradle.
I think there are many stupid things in these question and I google these questions, but end up with deciding to ask you guys as you guys can clear me formally and casually.
please answer my question if you know this thing deeply.
Android Gradle Build systems are software tools designed to automate
the process of program compilation .
How to know what is new gradle version is going on.
The Android build system uses the Android Plugin for Gradle to support
building Android applications with the Gradle build toolkit. The
plugin runs independent of Android Studio so the plugin and the Gradle
build system can be updated independently of Android Studio.
You can Mouse Hover On classpath for checking latest Version .
How to know which things are now forbidden in the new version of gradle
You should check Android Plugin for Gradle Release Notes
For classpath 'com.android.tools.build:gradle:1.3.1'
Fixed the ZipAlign task to properly consume the output of the
previous task when using a customized filename.
Fixed Renderscript packaging with the NDK.
Maintained support for the createDebugCoverageReport build task.
Fixed support for customized use of the archiveBaseName property in
the build.gradle build> file.
Fixed the Invalid ResourceType lint warning caused by parameter
method annotation lookup when running lint outside of Android
Studio.
Now For your 3rd and 4th questions you should check manual testing .