Android studio - MainActivity not declared over and over - java

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.

Related

Weird android system behavior if application is running more than ~8 hours

im currently building a digital signage app, which is running on displays which are based on android 7.*. Everything is working perfectly, except a weird OS behavior:
After a while (6-9h) of running the app, android minimizes my application, i don't get any error logs nor do i get a exception thrown.
My workaround solution is that im reopening the app every 2 hours, this is working fine, but its not what it should be.
I already tried it with WakeLock, Keep alive, Kiosk Mode, nothing seems to be working.
Does anyone have a idea how i could solve this android behavior?
I am getting pretty frustratet. PLS help :)

Code completion XML not working on Android Studio

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

App does not load in emulator

I am facing this issue for quite long time.
Creating a small android app
Whenever I try to run my Activity.java file in Android,emulator opens. After that I keep seeing this message as "Waiting for the target device to come online" for around 10 minutes. After that,when the gradle build gets finished, emulator stays as it is and app is not loaded or visible in the emulator.
This has happened to me many times and I failed to resolve this as I don't see any error message when gradle build is finished.
Any help is much appreciated. I have an assignment lined up to be completed in 2 days. Please help
Thanks,

My android app randomly stopped working

I have a bit of a weird situation. I finished coding my application last week and it was working perfectly fine. I launched it every now and then and it worked as expected. All of a sudden when I launched my application yesterday it stopped working. It produces no errors but sometime the screen goes black when I launch the app, some time it freezes and I can't do anything, sometimes it doesn't go pass the first screen.
I am really confused what happened as I am still running exactly the same code. Even when I try my previous backups it still does the same thing.
I have tried cleaning, rebuilding, running from different machines, running on different android device, clearing caches, data, uninstalling and reinstalling.
I have tried everything now but I can't figure out what the issue is. I am still running exactly the same code as it was 1 week ago when it was working all fine.

android's hello world tutorial application is not working

I am new to java and android and wanted to see how developing for android works
I started by downloading the SDK FROM HERE
However after I finish making the Hello World project sample given in the website HERE, if I try to run it on the emulator as explained HERE, the emulator screen appears, but nothing seems to happen. I can see the word android on the middle of the screen with some animation happening, but that's it. The website says something about unlocking the emulator, but I have no idea what that means. What I have gathered from reading other posts is that the emulator is supposed to have some kind of slider switch as in real smart phones which should be dragged to unlock it, but I can't see it in my case. Now I have no idea why this is happening or what I should check out in order to fix this. Are there any installation logs or something else that I can check to see what the settings are?
What I have tried till now:
I downloaded the SDK ADT bundle from HERE and just unzipped it. Then looked for eclipse.exe and ran it directly. Is there anything else I should have done prior to this?
When I did it for the first time, I had only JRE installed and not JDK, which I realized after reading THIS POST. So I downloaded JDK from HERE, updated the required environment variables and restarted eclipse, but still it's the same thing.
I looked at the Eclipse isn't talking to the emulator section GIVEN HERE, but all it says is to restart eclipse and the emulator, and it doesn't do anything at all.
Rant:
I can understand if the program had failed to compile when I didn't have JDK , or if the IDE gave any indication at all of a faulty program install, but that isn't the case. Everything seems ok, there are no errors, but it just doesn't do anything. This is the type of thing that makes people pull their hair out, and personally, I think the With a single download, the ADT Bundle includes everything you need to begin developing apps: in the android website is very misleading, especially for complete beginners
Anyway, what should I do to make the tutorial program run on my computer? My computer is a bit old and slow so could that be an issue? My computer is Windows XP SP3 on Intel(R) Pentium(4) 4 CPU 3.20 GHz 3.19GHz 2.50GB RAM, but if that was the case I assume the emulator shouldn't even start up
You just have to wait a bit longer. Android loads pretty long on emulator.
Tutorial says about unlocking, because when Android is loaded, your screen on emulator will be locked.
If you find emulator too slow for you, you may want to check this topic out: Why is the Android emulator so slow? How can we speed up the Android emulator?
I had the exact same problem as you when I first got into Android development a week ago. The two things I did are simply
1) Set the usable RAM on your AVD to 768MB
2) When you run your Hello World program in your emulator, give it about 5-10 minutes. Don't touch or click the window at all, just let it load up. Later you can make it persist
3) If your home screen comes up, click and hold the mouse button in the center of the screen, then drag towards the sides and release, this should unlock the device.
Try these steps first, if they don't work then there is likely a problem with your AVD configuration.
If you are launching your app first time with emulator, it will take appropriate time.After that, on Lock icon click and slide to the right. then you can view you application. If not check for your app(icon) installed.
By seeing your configuration of PC I think it will take some time to load emulator. After emulator is load (see below image)
then and then run your code and also check in eclise-device that whether emulator is online or not.
For checking emulator in eclispe :
In second image just above windows logo you can see small rectangular button with plus sign click on that you will get list from which you can select devices. You can find similar button in you eclipse at the bottom.
I had the exact same problem and followed the exact same steps, but was also unsuccessful. I ended up creating a new AVD with a Nexus 4 instead of the latest Nexus 6. The resolution of the 4 is much lower, which I think is what solved my problem. It loaded much more quickly using the 4.
Also, When I was using the 6, I could only see "ndroi" because the size of the screen was much larger than the size of the phone. Now I can see the full device.
vs.
You may just need to relaunch the Android studio 3.6.3.
I got a similar problem. The hello world app does not install on the emulator.
Problem solved after relaunch.

Categories