Android Studio layout Error : Unknown attribute - android

Android Studio Code Completion seems not working on xml and also it doesn't recognize any xml attribute except the attrs on Android support v7 views.
Screenshot:
my views that is from android.support.design.v7 display correctly:

I had this issue for a while and tried all the "solutions" provided;
Sync Gradle files.
Invalidate cache.
Removed and re-add project.
Reinstall Android Studio.
Nothing worked, until I came across this answer (by 4gus71n) which has worked for me every time this rather rare, but annoying issue has presented itself: https://stackoverflow.com/a/53160674/5692877
In my case I;
Closed Android Studio.
Cleared the contents of the C:\Users\MyUsername\.AndroidStudio3.2\system\caches\ directory.
Relaunched Android Studio.
Worked a treat!

If you are Android Studio then go to tools and then Android then click on build with gradle, it will solve the error. I encountered it too.
Tools->Android->Build with Gradle

Related

android studio projects getting corrupted after a restart

After upgrading to arctic fox, I faced this issue. Opened a project I worked previously with older version of android studio was fine, but after restart its files became full with gibberish values. I thought its a hardware failure issue. But this happening again today with other projects, so I want a solution.
After working, closing and reopening the project the files contents became corrupted/changed:
File contents changed on previous project, showing difference with git:
ArcticFoxPatch2, Projects are built with gradle 7.0.2.
Solutions tried:
I have tried potential solution of invalidating cache and restart, but the files stays same.
Android studio warns and suggest wrong encoding but reloading with multiple other encoding did not resolve file contents.
What should be a solution?
Should I change hardware, eg ssd? or downgrade android studio?
Please run android studio like this.
Click Android Studio and click right button on mouse, then click "Run as Administrator".
Hope it helpful for you.

How to fix 'Waiting for build to finish' error on Android Studio 3.5

While I was working on a view on my project, Android Studio suddenly started to show me 'Waiting for build to finish' message when I try to edit some layouts.
I have researched on the Internet and none of the solutions worked.
Things I've tried:
Removed .gradle folder from root of my project and from my home
folder (MacOS)
Uninstalled and reinstalled Android Studio with all it's leftover files. It was a complete removing.
Tried to tweak androidx library versions.
Clean / Rebuild Project
Invalidate cache and restart
Try on an empty project
Try on an existing but different project than I'm having trouble with.
Updated to latest version Android Studio 3.5
Updated to latest gradle and gradle plugin
In short, nothing on the internet or on the stackoverflow helped me.
Edit: I have solved the problem by myself.
Solution is found by myself.
If Android Studio keeps telling you waiting for build to finish, it's actually waiting for build to finish.
Sometimes people get confused when the status bar of AS says 'Gradle Build finished' but actually it's important to check the actual build is completed or not.
In Build screen there's a tab called 'Build Output' and I noticed that my app poped up some errors related to androidx and android support libraries. So I went back to non androidx version of my project and everything seems to working just fine.
There was a dependency for camera view using androidx and so I migrated my whole project to AndroidX because I was depreate enough to use that library no matter what happens. It ended up taking my whole day for fixing it.

Android Studio 3.0 xml-layout file's preview not showing

When I open layout file in my new Android-Studio file and press preview tab it'll show a message Waiting for build to finish... for infinite time.
Has anyone faced the same issue or any solution?
Cleaning and rebuilding my project solved the issue.
try different theme (may be from Appcompat) and API level from top
OR
If you have made some changes in the layout just undo it.
delete .idea and .gradle folder from root of the project
close android studio , restart it
click on gradle icon from right sidebar and click sync icon to refresh project.
now rebuild the project and it should work.
After a lot searching and I tried all solution which people give here, but any of them didn't solve my problem, I guess this problem is from studio's developers, and they may fix it in next patch.
so I simply re-installed my android studio and it's solved.
Try Clean and rebuild project.and Also try Invalidate caches/Restart.And this issue is also facing because of Low Ram in laptops.
After upgrading to Android Studio version 3.1, in the Project Structure dialog the build tools version was empty. Selecting a build tools version solved the problem for me.
Hope it helps for someone facing the same issue.
See my response on similar question posted:
Android studio error java.lang.IllegalArgumentException: Resource name cannot be empty
This error can occur when you update to Android Studio 3.0. It doesn't affect your ability to build a project, but the error does not allow you to visually see your xml layout files. You will also get the error when committing files to GIT, but you can still commit and push.
What I found in one of my projects is that a file was added to the "menu" folder automatically upon Android Studio upgrade, and the file had no name. It was named simply ".xml". All you need to do is delete the file and clean your project, allowing a new build of the project. That should take care of the issue.
For me I had this problem with one file, so I simply created a new one with the same code.
Simply make a build from within AS - not the command line. I get this all the time because I'm mostly using the command line. It's been like this since early versions of AS so I recon it's not high on there list of issues.
Lately (3.2) there is a lot of new internal crashes and what not - not stable at all 🤐

Android Studio unable to run project: NoClassDefFoundError: com/intellij/notificataon/Notification

I haven't found solution for this. Whenever I click run project, nothing happened. After several times hitting the run button, I realized there are plenty of "NoClassDefFoundError: com/intellij/notificataon/Notification" showed in the Event Log. Isn't it error because of the typo in "notificataon"?
I was just fixing some minor bug and I tried to run and this happen. before this everything run fine.
I tried to clean, rebuild, invalidate cache and restart android studio, same problem still presist.
Is someone have idea what's going on? How to fix the "notificataon" part ?
EDIT:
it's fixed for now but I still can't figure out how to fix this bug. I ended up re-install Android Studio and now it works again.
There is a 'ghost' bug with Android Studio and people have reported that the problem can be fixed with one (or more of the following) :
1) There is a conflict between the project's android support library version and the version in its library projects.
Set the same version to the android support library in the project and in the library projects that are included and then run build clean.
2) Clean Android Studio's cache by doing File->Invalidate Caches/Restart
3) Look for broken inclusions (such as .jar files that have changed and/or been removed) and solve them (add new/incorrupt versions)

Layout Rendering issue android studio 0.8.0

I had a working project in eclipse. I made a new project in android studio and remade the same project here by copy pasting the code(I have too much problems with importing, so I preffered to make the project afresh). I loved everything in android studio except the rendering issue withe the main activity xml file. I have copy pasted the xml file as such from the eclipse project where it was working perfect. But in android studio it is showing rendering error. In fact android studio is taking none of the resources i have in the drawable/dimen/string/color, nothing to show and it is always showing this error message:
NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts
I have gone through the entire thing and everything is well. The program is even running smoothly with the screens perfectly as it is. I just can't use the interface builder. What can be the issue here? How can I resolve it? Do I need to import something?
Ok.. It seems like the same fix as of eclipse works on android studio as well. I had previously tried rebuilding the project, cleaning and building again and everything, but closing android studio and restarting solved the problem. It is just that after restarting android studio, you may have to wait for some time until the sync is finished, but it is working perfectly well now.

Categories

Resources