Code completion XML not working on Android Studio - java

I was working on an android project for homework, and suddenly, while I was designing a layout, I realized that the code completion wasn't working, and I don't know why.
Here I post some photos:
XML not completing
However, when I try to code some Java, the completion is working.
Java does complete code
I don't know how to revert that, I tried to Invalidate Cache, turning off power saving mode, and nothing works.

Change your gradle version from the one you are using presently. Then close and open project again.

Try restarting studio and Sync Project with Gradle files

Related

Android studio - MainActivity not declared over and over

I'm using Android studio 3.4.1 on Windows 10 x64 and I'm constantly getting same error over and over.
I can't run the app, because "MainActivity is not declared in AndroidManifest.json", and all code that uses something that requires permissions (NFC, read/write files, atc.) is marked as error, and the message is claiming that the permission is also missing in manifest.
These errors can be simply solved by Syncing grande files, as stated in this question: The activity 'MainActivity' is not declared in AndroidManifest.xml
However, after few minutes, these errors are back there again!
I've tried restarting the IDE many times, invalidating caches, syncing gradle many times...
But nothing helps. I got these errors, I sync gradle, errors are gone, I run the app, make tiny changes in code (like changing string in setText or changing textview margin), try to run it again, and the error is back. I sync gradle again, error is solved, I run the app, then I leave the IDE, Google something, and when I return to the IDE, the error is again back, even if no changes were made to the code.
I tried to Google this issue, but I was only able to find questions where this happend once.
Obviously there something that makes the Android Studio "forget" manifest every few minutes. The issue started to occur after my computer once lost power and shut down, so my first idea was corrupted files (as it could have happend while Android Studio was saving something), but if I ran the app after grande sync, it works fine, and it lasts few minutes before the errors are there back again.
So, as this issue happening once has been asked many times about, and many times there were different replies, I just started trying other suggestions.
I came acros this reply: https://stackoverflow.com/a/52687462/6357453
which suggests deleting folders with cache and other stuff Android Studio has created. I did and as of now, it's been more than an hour without this error, so this propably solved the issue.

Android Studio - package java.awt.image does not exist

I have a problem running my project on Android Studio. I am working on an Android project that has a native Java library inside it. It was running fine all the time. But suddenly when I open Android Studio, I find this error:
There is also an error in the .gradle of the project:
It says that URI is not registered.
When Android Studio is started, I find this message:
It seems that there is something wrong in Java configuration, but I can't find out what is the problem?
It was running fine all the time
Not on Android, it wasn't.
It seems that there is something wrong in Java configuration
No. You are using classes that are not part of the Android SDK.
The java Swing and AWT API are not part of the Android SDK and thus aren't including with it. You must find an Android equivalent image library to use in your app. There are few good ones around just depends on what functionality you need to have available to you in you app. Try searching Picasso and or Volley. Picasso is very popular and well known. it has a lot of feature including networking functionality for loading images from the web. The Volley library isn't an image library but an networking library that contains some predefined classes for loading images over the internet.
So this just happened to me. I'm not 100% on the details of how I got it working again, but its roughly this (on my Mac):
Quit Android Studio
I went to ~/Library/Application%20Support/ and deleted the AndroidStudio3.2 directory
I relaunched Android Studio and I got some warning dialog about plugins not existing.
Chose the button that is something about reinstalling or fixing (or whatever isn't deleting or ignoring)
Another dialog comes up. There are a bunch of plugins that are in red. Deselect all the red ones. Then reselect all those ones that were previously red.
Android Studio asks you something and if you want to restart Android Studio. Pick the thing that includes restarting.
And once Android Studio restarts, chose to rebuild your project, and then it worked.
Good Luck and I hope this works for you too.

Eclipse Programs to Android Studio

Is there any way I can call .java files from eclipse to programs in android studio and have that code be run from android studio? I cannot have the code directly copied into android studio as it brings up multiple issues. So I am wondering if there is some way I can call the .java from Eclipse, get the result from the method within that Eclipse program, and pass that result to android studio.
Any help would be greatly appreciated!
Very simply, no you can't "just call" code from another IDE.
You could export the Eclipse code to a JAR, import as a library into Android Studio, then try to work around that, but that sounds like a lot of work.
In regards to your previous questions, plus your comment.
it was working in eclipse, but when I literally copy and paste that exact same code into android studio, I am getting network issues when I run it.
Android has a UI Thread that does not like to handle Network requests like your bare single-threaded Eclipse project.
You need a separate thread. Without any libraries, there is AsyncTask, and the Android documentation covers this.
Though, you may find OkHttp to be better documented, useful, and less confusing than AsyncTasks. Volley is another, though works fine, is not very well documented.
See more discussion at Comparison of Android networking libraries: OkHTTP, Retrofit, and Volley
No, This is not possible way to do. Android studio and eclipse are different Applications and you cannot pass the Result to each other.
You can import the project or copy the files for a new Project.

Android development issues using eclipse mars

I'm having an issue starting my android development as I've tried multiple solutions off this site for getting past eclipse not building blank activities and its not letting me begin my development and I have also tried updating and downloading the SDK but all my attempts have all deemed unsuccessful, could this be because I'm using eclipse mars.
My recommendation would be to start using intelliJ IDEA. Just becouse you can do almost everything inside that one program and it seems to be faster than android studio for me.
Here is the download link: https://www.jetbrains.com/idea/

Hot code swap in Android Studio with libgdx

I am using Android Studio (IntelliJ) to program Android apps and am facing a problem with hot code swapping and libgdx.
When I run the desktop application in demo mode everything works fine. If I try to change a bit (e.g. the color of an element) nothing is refreshed in the application. Even if I select Run->Reload changed changes a new gradle build is started (takes very long) and then says couldn't find any changes.
I have imported the same sample application in eclipse. There I can just change something in the code and it is immediately shown in the running app.
Anyone else experiencing this issue? Why is this not possible in IntelliJ?
Unfortunately, hot swap debugging does not appear to work when using the Gradle template.
It is actually possible as specified here, you need to disable the Android Support plugin if you want hot code swap to work with Gradle and libGDX.

Categories