Android Studio shows error for every line - android

Android studio showing error for all lines in the project. I am able to run the app in the device. I tried invalidate cache and restart, that didn't help. Please check the screenshot below.
I believe, it is something related gradle or android studio!! But not sure where to make changes.
Android Studio version 4.1.2

Try this:
Make sure, gradle isn't in offline mode
Clean project
Remove .idea and .gradle folders from your project
Invalidate caches and restart
Sync gradle and rebuild project

Related

Why are my files still being 'Analyzed' in Android studio, intellisense and autosuggest doesnt seem to work

For this particular project, Android studio just shows analyzing files, doesn't show any errors and the IntelliSense is also not auto-suggesting. I have tried to invalidate cache/ restart, checked that android studio is not in power mode, and also deleted the project locally and cloned it again, what can be the issue?
It was working fine till 2 days ago but today when I opened the app and tried to build it and make some changes to a few files, it just wont work.
I am on Android Studio 4.2.1 on macOS Big Sur 11.2.1
If I create a new project the studio is working fine but just for this project its not working
Here are the screenshots
Any help is much appreciated! Thanks!!
I have posted the same answer in another post, you can take the reference from the below link.
https://stackoverflow.com/a/67984260/11414681
You just need to Upgrade the latest kotlin version.
Upgrade the dependency in the project's build.gradle file.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
Upgrade the dependency in the app's build.gradle file.
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.10"
Delete .idea , .gradle andr buid folder from your project path.
After delete your project from Android Studio and re-open and its work.
Sometimes android studio has been not working properly so ignore this bugs its nothing.
Just make File -> Invalidate caches and restart
Check my answer here, stackoverflow.com/a/68755611/2281717
In my case, I just update all dependencies on my Android App Project. And it's working

my layout folder get red lines after migrating Android Studio from 3.6.2 to 4.3.1

This is kinda weird
I just recently migrated my android studio from 3.6.2 to the latest version because of some need. When I reopen a project that was build from 3.6.2 there's suddenly red lines on the layout folder like this
The problem is , when I tried to run the project it will build and run successfully without any error. And there's no way to know what or why it got marked as error. This is kind of annoying, anyone know how to remove those red lines?
Try restarting Android Studio without caches.
File -> Invalidate Caches / Restart... -> Invalidate and Restart
If that doesn't work try cleaning them manually. Read this.

Android Studio 3.3.2 Stuck at Project Setup:reading from cache

I recently installed the new version of android studio, but every time I reopen a project, the gradle configuration automatically tries syncing to the project, which is perfectly normal.
However, the sync never completes and is stuck at
Project Setup: reading from cache.
Someone know how can I fix this?
I have also found AS to be pretty slow, it just stops/hangs and then resumes. This might not solve the problem completely but can be tried. Destroy the .gradle folder and .idea folder (extreme case destroy the main .gradle folder on you computer home directory). Once that is done, re-import the project in AS. These directories maintain local cache data, which might be causing these issues.
According to known_issues_with_the_android_gradle_plugin:
Configuration on demand with Gradle 4.6 and above: If you're using Android Gradle Plugin 3.0.x or 3.1.x with Gradle 4.6 and above, you should disable configuration on demand to avoid some unpredictable build errors. (If you are using Android Gradle Plugin 3.2.0 or higher, you do not need to take any action to disable configuration on demand.)
Disable configuration on demand in your gradle.properties file as shown below:
org.gradle.configureondemand=false
Also, note that Gradle caches directories
On macOS/Linux: $HOME/.gradle/caches/
On Windows: %USER_HOME%\.gradle/caches/
Try to close your Android Studio and delete those directories then restart Android Studio.
More about build caches is here: Android Studio Build Cache

Unknown Android XML attribute

First, I really dont know wth goin on with android studio ver 3.2.1. I got too much bullshit errors after update this version. Funny thing is i do nothing. After update, everything is fine, but when i restart IDE. everything go wrong.
I tried clear caches, re-install Android Studio, Invalidate Caches, Re-sync project with Gradle, clean project, re-build project. But, nothing change. So, i hope someone can help me. Thanks so much!
Try these:
Method 1:
Delete the .idea folder that is in the project location
Build > Clean Project
Then change something in the app level gradle
Then android studio will ask you to sync the project. Go ahead and sync, the problem will be gone
Credits: https://stackoverflow.com/a/47825463/10471480
Method 2:
Try cleaning up of the following folders:
c:\Users\<user>\.gradle\caches\
c:\Users\<user>\.AndroidStudio3.2\system\caches\
100% Working
Do this two steps:
1.Go to folder where you android studio caches are located. I have android studio 3.6.3 For me it's "C:\Users\Lenovo.AndroidStudio3.6\system\caches"
2.Go to the folder where you android studio projects are located. Open the project >then .idea folder and delete the caches. For me its "C:\Users\Lenovo\AndroidStudioProjects\MyDictionary.idea\caches"

Gradle project sync failed?

When I started up my project this morning it randomly gave me a message saying Gradle project sync failed. Basic Functionality(eg. editing, debugging) will not work properly. in Android Studio. I looked at other answers that people had put up for this problem but they haven't been working. I invalidated my chaches/restarted my project but no luck. I also deleted my .gradle folder from my project folder and still no luck. If any of you guys could help me that would be awesome! This didn't happen yesterday when I was working on the project or anything, I wonder why its happening now. Oh yea it also says this as a gradle message: Error:C:\Users\Dave\.gradle\caches\2.2.1\scripts\settings_ad4t0wp5ikihzl1y1o83b5sbw\SettingsScript\buildscript\cache.properties (The system cannot find the file specified) :
Thanks again for anyone who reads this/ can help!
There is a file - "cache.properties" that gradle creates for you, upon first time inception of any project. The path for this file is "~Home_Directory\.gradle\2.2.1\taskArtifacts". You may find this path in your home directory. So basically, this file - "cache.properties" is missing from the "taskArtifacts" folder.
One of the solution that worked for me is to copy file - "cache.properties" from any test project of yours to this project that's currently experiencing an issue.
Regards
I had to choose using the Default Gradle Wrapper instead of local.
<< SETTINGS -->/ BUILD TOOLS --> Gradle --> radio button switch... >>
It has helped me to fix the same problem.
I had experience similar sync failed problem with gradle based android project (in Android Studio 1.1.0). I solved this problem without deleting .gradle from my user directory,
steps I followed was
Go to File -> Settings -> Compiler(Gradle Based Android Project)
Change VM options to -Xmx512m -XX:MaxPermSize=512m.
Click Apply -> OK and then tap on Try Again option in sync failed message to clean build the project.
Works like charm!!
UPDATE - 1 : For Android Studio 1.3, Compiler option mentioned in above Step-1 is present inside tab Build, Execution, Deployment.
I had faced similar kind of problem earlier!
But don`t know after rebuild the project and cleaning it, it worked normally.
Invalidate dependency cache by running
gradle clean build --refresh-dependencies
from project root and then re-import your project. Worked for me once.
May be you have put Android Studio into offline mode. To fix it, go to Preferences -> Gradle and ensure that the "Offline work" checkbox is not checked.
Than do
File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Restart Android Studio let it download all the Gradle stuff it needs
android studio 0.4.2: Gradle project sync failed error
Delete the folder C:\Users\.gradle and reopening the android studio solved my problem

Categories

Resources