Android databinding generated files disappears when coding - android

I am facing a strange problem when Fragment*Binding files are deleted while I am writing code (all references become unresolved, generated files absent in files system) that can be fixed by clean project-> make the project but it is time-consuming.
Such behavior occurs 3-4 times per hour.
Originally I thought I might be deleted by antivirus software, but I checked that all paths related to development are in Av exceptions.
Android studio bumblebee latest updates (happened few updates before too)

I had the same problem and it was because of gradle, for a while i changed the gradle version (lower or higher should be tested) (requires invalidate cache and restart), then worked with that gradle for a while then changed it back and it was fixes

First make sure that the dependencies you are using are updated to their latest version also your Gradle and Gradle Plugin are latest and compatible with each other.
Also check if you are using the latest Android Studio Bumblebee version which is
2021.1.1 Patch 2 Built on 17 Feb
Shortcut for clean or rebuild project :
Press Shift Key twice and then search 'clean' or 'rebuild' and press Enter

Related

Compilation time in Android Studio is more than one hour

Faced with such a problem that the application compiles for a very long time. I tried to clean the cache - with no result
Changed the settings in build.gradle - no result
Moreover, I have a similar project in terms of code volume and it compiles on the same configuration files for no more than a couple of minutes.
Android Studio Fox 2020.3.1 Patch 3 -
AGP 7.0.4 -
Gradle 7.0.2 -
Kotlin 1.6.21
Fixed by deleting kotlin-android-extensions and rewrite all code where was it by used
Try invalidate cache and restart. if it doesn't work delete .gradle folder under user folder. If it doesnt work too. You can try stable Android Studio version. Because you use canary version it may be real source of problem. You know it is very buggy usually.

Android Studio uses wrong different SDK version for different classes

I faced a problem when Android Studio started marking code in red:
When I click to view source of findViewById() it takes me to sources of Android SDK 16 which is different from my project's compile SDK version (29).
At the same time in some other classes within the same project there is no such problem and findViewById works well. Clicking on it brings me to Android SDK 29 sources which is correct.
My project has compile SDK version set to 29, it's dependencies use compile sdk from 16 to 25.
I already tried:
Clean project.
Rebuild project.
Invalidate Caches / Restart
Reinstalling Android Studio and installing Beta version.
Tried to use different GIT commits where no such problem existed.
Deleted /.idea and /.gradle folders.
When I delete sources of Android SDK from ~/Library/Android/sdk/platforms/android-16 it helps until next rebuild (then Studio automatically downloads it again)
What started the problem: to fix GIT history I removed all files from working directory and copy-pasted a new version there. Not an elegant solution, I know, but there were no problems in git difference. The thing is that this "red code" problem now exists in all previous commits.
Project compiles without errors and application can be installed!
Please help!
Update: this problem arrises only in Fragments! Somehow getView() in Fragment give me a different version of view?
Solution found:
update implementation 'com.google.android.material:material:1.1.0' to version 1.1.0. Don't now why this dependency started creating problems.

Android studio IDE shows unresolved references / ignores imports, while builds are fine

Since couple of days I have problems with my android studio IDE, quite desperate at the moment. Various library imports are not recognized any more (some are, some not, junit e.g. isn´t), showing me unresolved reference error and autocompletion isn´t working as a consequence. But it´s only the IDE, gradle builds are fine.
Gradle files should be fine, the pic is from a new project where everything is set up properly. Same problem with old and new projects. I tried like everything already:
Deleting .idea folder + .iml files and reimporting the project
Invalidate Caches / Restart...
Deleting .android/cache
Deleting HOME/.gradle/caches
Downloaded and installed new Android Studio (v3.2.1), opened old, started new projects
Switched kotlin plugin versions, compilesdk versions, android gradle plugin versions, kotlin versions, gradle versions
I did couple of updates at the same time, Android Studio to 3.2.1, Kotlin plugin to 1.3.0, android gradle plugin to 3.2.1, installed newest sdk 28, switched from gradle 4.6 to 4.10.2. Shortly before, I had another weird behavior, where opened files didn´t show the real content but instead cryptic, binary symbols for nearly all the gradle or source files. Only deleting whole project folder and recloning it from git solved that one. I blame a hard reset while studio was running for that. As if anything android studio related on my machine is messed up. But even new installation of studio does not help
Ok, finally solved the problem by completely removing all android studio installations (using the included uninstall.exe), deleting HOME/.android and all HOME/.AndroidStudiox.x folders, then reinstalling android studio (not finding anything from previous installations anymore). Could then even reimport my settings, exported previously

Android Studio 3.1 Stable. Build Successful but Can Not Resolve Error

I have updated to Android Studio 3.1 Stable Version today(27 March 2018).
I have an old project. With new studio version, it gets build successful and app gets installed on Emulator, but the on the IDE, Activity file shows
Can Not resolver Error
.
gradle file app module
Project level gradle file
I spent a long time on this yesterday after migrating from Android Studio 2.3 to 3.1. Tried everything from other answers to similar questions. Google's maven repository was correctly configured, tried invalidating caches and restarting, restarted the computer, etc.
The one thing that worked for me was closing Android Studio, deleting the .idea folder from my root folder and starting Android Studio again. Since I had everything checked into git before starting the upgrade I was able to do:
rm -rf .idea/
git checkout .idea
So I ended up with my original idea project files, but you should be fine if you can't revert to your checked in idea files. After reopening Android Studio it recreated some of the files I ended up deleting and everything worked again. Hope that helps others with the same problem.
This answer is old but basically suggests the same thing so I guess this problem keeps showing up. https://stackoverflow.com/a/21100896/791560
I was able to Fix:
https://developer.android.com/studio/build/dependencies.html#google-maven
From Android Studio 3.1, if we are working on Old projects built on 3.0 or lower, you need to add maven repository at top level build.gradle file. i.e., add google() under repositories of all projects.
For new projects, it gets added automatically.
App level, build tools version should be at min 27.0.3
Make sure compilesdk version and support library version are the same version level.

Synchronize Gradle and Android Studio Versions

Android studio was taking up a massive amount of disk space on my computer (over 50 GB) and my old 90 GB ssd was completely full. I tried to reduce the amount of space that was being used by completely removing everything from android studio except my project and then reinstalling it.
There were some problems that I worked through, such as updating the sdk version, but I am stuck on this error message:
Error running app: This version of Android Studio is incompatible with the Gradle Plugin used. Try disabling Instant Run (or updating either the IDE or the Gradle plugin to the latest version)
I tried disabling instant run, but it did not fix the problem, and I like instant run anyway.
I also tried installing a new version of gradle and then pointing to it in settings/buildtools/gradle, and I've also tried checking the box to use the default wrapper instead.
I tried modifying my class path in build.gradle when I changed to gradle 3.0 in the settings above:
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
My android studio is version 2.1.3/143.3101438
How do I get the right version of gradle installed and update my project to use it?
I got it working now. I had to specify the version of gradle in three places. First in settings/buildtools/gradle set it to use the default wrapper. Second specify the gradle version in build.gradle:
classpath 'com.android.tools.build:gradle:2.1.3'
Third, in gradle.wrapper.properties specify the gradle version:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
(I originally set it to ...gradle-2.13-all.zip, but it changed it to 2.14.1 after i put in 2.13, but it did not update the version in the build.gradle file)
I'm still very much confused what gradle is doing, why I need to specify the version 3 times, but at least it works.

Categories

Resources