Never_be
Never_be

Reputation: 849

Android studio compile error "Content is not allowed in prolog"

I use latest Android Studio 0.8.4 (for OS X), in "res" directory I create new "database" directory and put there all files what I need and when I try to compile I receive this error.

Error:Content is not allowed in prolog.
:app:mergeDebugResources FAILED
/Users/filipp/data/Android_dev/project/app/src/main/res/database/5clSubject0Book0.txt
Error:Error: Content is not allowed in prolog.
Error:Execution failed for task ':app:mergeDebugResources'.
> /Users/filipp/data/Android_dev/project/app/src/main/res/database/5clSubject0Book0.txt:0:0:   Error: Content is not allowed in prolog.
Information:BUILD FAILED

Upvotes: 28

Views: 81013

Answers (11)

Kazi Mahbubur Rahman
Kazi Mahbubur Rahman

Reputation: 155

In my case, I had a comment /* launch_screen.xml */ at the beginning of my launch_screen.xml file. After removing /* launch_screen.xml */ comment from my code I was able to solve this issue

code image

Upvotes: 0

Mathieu
Mathieu

Reputation: 1713

Perform Build Clean and Rebuild Project did not work for me.

I had to manually delete .idea/caches, then rebuild project.

Upvotes: 0

Kieron
Kieron

Reputation: 2028

Old question but googling the error got me here.

This was fixed for me by deleting the (empty) "navigation" folder from res, it was left over when checking out a different branch from a repository, appears it can't be empty or it will cause this error.

Upvotes: 8

Amjad Khan
Amjad Khan

Reputation: 1317

I am having the same problem What I did is,

You need to clear the cache data

Go to Build(Menu)--> Clean Project

Then

Go to Build(Menu)--> Rebuild Project

Then Run Your project

This may also help in refreshing data of android preview

Upvotes: 18

Prakash G Khaire
Prakash G Khaire

Reputation: 51

Try the following steps

  1. Go to the Build Menu.
  2. Select the option Clean Project.
  3. Once again, go to the Build Menu.
  4. Select the option Rebuild Project.

It worked for me.

Upvotes: 3

Gaurav Agrawal
Gaurav Agrawal

Reputation: 313

You can only have predefined set of folder inside res folder. so you are creating database folder inside res folder which is invalid. Either put database files inside assets folder or raw folder.

Upvotes: 0

Taani
Taani

Reputation: 71

I faced the same error when I created assets folder inside app/src/main/res/

We shouldn't create folders anywhere at our will. To create new folders, make sure that you go to
File -> Folder and consequently ,choose one of the folders among the options displayed. This way the IDE creates the folder at appropriate locations and thus accessing them doesn't raise any errors.

Upvotes: 1

DiscDev
DiscDev

Reputation: 39052

In my case, I had accidentally entered a random character right before the beginning of my strings.xml file.

enter image description here

I removed the "f" character before the xml declaration and all was well again.

Upvotes: 14

Tushar Varshney
Tushar Varshney

Reputation: 11

I removed all of the compile statements. Then, I deleted the jar files from libs (and selected 'safe delete'). Once that was done, I dragged the jar file back into libs. Once there, I right clicked on libs selected to add it as a library. Now the gradle builds fine and everything works.

Upvotes: 0

Arthur
Arthur

Reputation: 2639

You might want to clean caches

C:\Users\<username>\.gradle\caches

Upvotes: 13

CommonsWare
CommonsWare

Reputation: 1007474

in "res" directory I create new "database" directory

That is not supported. You cannot invent new resource directories.

Please put the files in res/raw/ (and use via getResources().openRawResource()) or assets/ (and use via getAssets().open()).

Upvotes: 31

Related Questions