• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Can not run any of apps in Android Studio

RealMacleod

Newbie
Mar 10, 2019
13
1
Hi! Maybe someone can help me:)
I've installed the latest Android Studio a few days ago and began doing some online lessons.
I had no any troubles till yesterday. But yesterday I created a new module in my project and could not run it, getting a message in event log - "Error: Content is not allowed in trailing section." This message was concerning the colors.xml file, which has just a few lines inside:

<resources>
<string name="app_name">BasicViews</string>
</resources>


There is nothing to fix here.

After that I noticed that there no images in "mipmap". They exist in Studio folders but they doesn't exist in my project. I can just see a message - "Image not loaded. Try to open it externally to fix format problem".
I created a new project and some new modules, but I am getting the same error every time while trying to run my app.
Notice, that I am not trying to do any changes in project. I just want to run a new app from a new template to get "Hello World" at the virtual device.
Even after reinstalling Android Studio there was nothing changed.
Hope to get some help here. Thank you.
 
You will have a syntax error in your XML file. Check for any extra characters that shouldn't be there, like '.' or '-'
There can not be any of extracaracters, I hope. Because this code is generated by Android Studio and I didn't do any changes in its structure. And it worked perfectly till the moment without any troubles.

Post up a screenshot of what you see, including the error log. It's difficult to get the whole context just from that small code snippet.
Here you a screenshot. Thank you for your attention.
 

Attachments

  • android_screen.jpg
    android_screen.jpg
    299.2 KB · Views: 108
Upvote 0
Very bizarre! You know, I've been using Android Studio for a few years now, and I've noticed of late that the quality has declined. A lot. Things like random crashes, and my gradle daemon persistently dies. These problems did not previously happen, and I've been running it for ages on my Ubuntu system. It used to be absolutely rock solid. Yes they've added lots of new features, but quite honestly this seems to be at the expense of general reliability and quality. Not good, and not really an encouragement to use it.

Anyway, forgive the rant. Your problem as described, is really strange. You could try deleting the offending file, if the code doesn't reference those resources. It's quite strange that a string resource is placed in a file called colors.xml. Doesn't seem like the right place for it.
You could try adding the XML header at the top of the file

Code:
<?xml version="1.0" encoding="utf-8"?>

What do the other XML files in the folder look like?
 
  • Like
Reactions: GameTheory
Upvote 0
Looking at the screen shot you posted it looks like you have a string resource in the color.xml. That particular resource should be in the strings.xml file. In the color.xml you should have color resources <color ...> ... </color>

Edit: LV426 already pointed the above out. That is the issue.

Also you should always have the line that LV426 posted in post #11 at the top.

This is strange. Hello World always runs out of the box. Though lately Android Studio breaks with major updates. For me it's almost always gradle issues.

When the Hello World app is not created properly out of the box, it's always best to reinstall Android Studio.
 
Last edited:
  • Like
Reactions: Deleted User
Upvote 0
Very bizarre! You know, I've been using Android Studio for a few years now, and I've noticed of late that the quality has declined. A lot. Things like random crashes, and my gradle daemon persistently dies. These problems did not previously happen, and I've been running it for ages on my Ubuntu system. It used to be absolutely rock solid. Yes they've added lots of new features, but quite honestly this seems to be at the expense of general reliability and quality. Not good, and not really an encouragement to use it.

Anyway, forgive the rant. Your problem as described, is really strange. You could try deleting the offending file, if the code doesn't reference those resources. It's quite strange that a string resource is placed in a file called colors.xml. Doesn't seem like the right place for it.
You could try adding the XML header at the top of the file

Code:
<?xml version="1.0" encoding="utf-8"?>

What do the other XML files in the folder look like?

Your code unfortunately didn't help((
Concerning the other XML files. For example ic_launcher is empty. And all launcher icons are empty. I know that ic_launcher must contain code, and I even took it from another PC. But nothing changed. It must be some bug, but what can I do if even uninstall didn't help.
 

Attachments

  • android_screen2.jpg
    android_screen2.jpg
    180.6 KB · Views: 112
Upvote 0
Looking at the screen shot you posted it looks like you have a string resource in the color.xml. That particular resource should be in the strings.xml file. In the color.xml you should have color resources <color ...> ... </color>

Edit: LV426 already pointed the above out. That is the issue.

Also you should always have the line that LV426 posted in post #11 at the top.

This is strange. Hello World always runs out of the box. Though lately Android Studio breaks with major updates. For me it's almost always gradle issues.

When the Hello World app is not created properly out of the box, it's always best to reinstall Android Studio.

I put the right code in colors, and I added a piece of code in strings. But now another error appears(
I also reinstalled Android Studio and in didn't change anything.
 

Attachments

  • android_screen3.jpg
    android_screen3.jpg
    198.9 KB · Views: 127
  • android_screen4.jpg
    android_screen4.jpg
    184 KB · Views: 97
Upvote 0
Does your ic_launcher_round.xml look like this?
XML:
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@drawable/ic_launcher_background" />
    <foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

All of ic_launchers were empty. I tried to add your code. The resulting error you can see at the screenshot(
As told above, all the launcher block is empty: both code and icons. And it looks very strange.
I think the right question should be: How to reinstall Android Studio to make it forget all this shit?:))

How did you create this project?
Did you use File -> New -> New project
And what template did you select?

Yes, I created the project through File-New-New project with "Empty activity" template. Normally it must give as a result "Hello World" application.
 

Attachments

  • android_screen5.jpg
    android_screen5.jpg
    208.5 KB · Views: 95
Upvote 0
Ok I'm on linux so it would be difficult to help you trouble shoot with exact steps... On linux, if I had to reinstall, I would delete the AS config directory in my home directory and then reinstall.

The directory is hidden and called .AndroidStudio3.3

I don't know how windows handles uninstalls. If you uninstall AS would there still be such a directory left behind?
 
Upvote 0
As I feared, the OP is suffering from Windows 10 :p

I too am a Linux user, and as GT says, it's dead easy to nuke the AS installation. But unfortunately Win tends to remember things that you sometimes don't want it to. I'm not sure how to completely obliterate a software product's installation.

Can you run a VM with Ubuntu or some other Linux distro, or even dual boot into Linux? It'll make things run a lot smoother.
 
  • Like
Reactions: GameTheory
Upvote 0
Oh, please, no! Please, don't tell me about Linux:) I have too many things to do on my PC. Gaming, photoshop, 3dMAX and so on.
Maybe it is a good idea to install Linux on VM, but I have heard a lot about the bad stability of such system types. I also think that Androd virtual device may cause troubles in this case because it takes to much resources.
However guys, thank you very much for your assistance. I will read some more about AS deep uninstalling and tomorrow will write here my experience:) May be it will be helpfull for someone.
 
Upvote 0
Incidentally, the AVD (emulator) can be quite slow. I avoid using it, and prefer to develop with an attached real device. It's a lot quicker.
Although the emulator can be useful to test with older versions of the SDK.

Anyway, sorry we can't be much help on your issues, it really does sound like the AS installation is screwed.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones