My android app "stops unexpectedly" - java

I have recently got into writing android apps and have hit a brick wall very early on that I can't figure out, and i'm sure it's mind numbingly simple.
Everytime I run it in my emulator, I get the "Stopped unexpectedly" error :/
Files
The main ".java" file and the main.xml are in there, just scroll down.
EDIT: Fixed now, just needed a simple clean :3

Somewhere in your layout XML, there's an invalid element named EditText2. There's no such view in the Android SDK, remove the "2".

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.

Emulator in Android Studio won't load

Rendering problems. The following classes could not be instantiated:
- android.support.v7.internal.widget.ActionBarOverlayLayout .
Exception Details:
java.lang.ClassNotFoundException:
android.support.v7.appcompat.R$attr
^^^^^------- (The character represented by the '$' is another character I am unable to write. )
This is what shows up instead of my emulator in android studio. I deleted some projects before this happened and may have mistakenly edited a read-only file. I already tried reinstalling Android Studio and the Android SDK from scratch. Same result. Sometimes it will give an error related to utf-8 and give the option to open up the file encoding. It isn't doing that right now. This brings back the emulator but the drag and drop brings up a small window that can be changed on the emulator. And the problem comes back every time I restart Android Studio.
Is there anything I can do to fix this.
Thank you.
Have you tried to change apptheme? I know some rendering problems or error can be temporarliy fixed by doing this.
Try changing your base application theme using below code - in res/values/styles.xml
It seems to have fixed it for some people. It is also a bugg that will be fixed in a later version. Check the link for more info and some workarounds.
http://tools.android.com/knownissues#TOC-Can-t-Render-Layouts-in-Android-Studio-1.2

Adverts not appearing on my Android App - Google AdMob

I have made an android application and put adverts in using Google AdMob.
On Eclipse's Graphical Layout there is a white rectangle which says 'Ads by Google' in it, which shows that it has been set up properly.
However, when I run the app on the simulator and in real life, nothing shows up. Why would this be?
Thanks in advance!
You should make sure you have setup your Android Application properly with Ads, go over the following steps and ensure that you have done them correctly.
GoogleAdMob Jar in your libs folder
GoogleAdMob Activity in your manifest
GoogleAd AdView in your main activity XML file, with your adunitId correctly inputted
And Ensure your class in which your AdMob is coded in is correct.
Let me know if these steps help you or not.

Android appt.exe has stopped working

Hi I am new to android and am doing some new basic projects. Whenever I try to save a project the alert box saying "unfortunately appt.exe has stopped working appears" and all of a sudden there are many errors that can be seen. I can also see that the R.java file disappears automatically and I dont know what to do next. I read somewhere that to delete the id in style, but cannot see any Id in my styles.xml file. I even deleted the whole SDK and downloaded and started from scratch, so would love if I could find any solution to this annoying problem.

Initial lag when starting Android App

I'm working on a chess type app for the Android platform (using Eclipse and standard Java / XML connection). This isn't for school or anything, just a personal project after learning some of the fundamentals to "get my feet wet."
Anyway, my question isn't due to a direct problem, more to what I've viewing when I open the emulator and what I see in the logcat.
Generally, when I hit run for any app, the emulator takes its standard time loading it, but when it does, the main activity loads right away. However, for this app, I'm experiencing a lag after the app loads, and when I quickly glance over to the logcat, it shows a TON of orange messages being generated...and then it displays my board (the app atm is just displaying a board).
Here is the HUGE logcat activity (sorry about the pastebin, but I'm new to this site and was having difficulty formatting this properly): http://pastebin.com/skc8SXqN
And here are my xml and java files: http://pastebin.com/8ByBQ0TA
My question is...is there any obvious reason for why the ~5 second lag occurs between the app loading and the board showing up? The incredibly large logcat output is all directed to the imageview...so am I doing something heinously inefficient there?
The problem is that you should be supplying a drawable for the squareView.setImageResource() whereas you are supplying R.id.square_background which does not seem to correspond to a drawable resource.
Because here i seee you are referencing huge number of images in your project its normal for android emulator to slowdown your loading time of app.you can run it on device it will faster than the emulator..and put your image resources in drawable folder and reference them properly.
As you stated, it was in the general vicinity of the way I was handling the image array...namely, I didn't need it at all.
The getCount() method, if I set it returning a total number of squares I wanted, would simply cause create the square X times without using an image array.
Changed that and voila, no lag.
this is resolved entirely!

Categories