Reputation: 316
When i add a gif image in assets folder it gives me errors that Content is not allowed in prolog. Please help.
C:\games\work\DEGREE\Sem 4\Android Projects\CoolUI\app\src\main\res\assets\space.gif Error:(1, 1) Error: Content is not allowed in prolog.
Error:Execution failed for task ':app:mergeDebugResources'.
C:\games\work\DEGREE\Sem 4\Android Projects\CoolUI\app\src\main\res\assets\space.gif:1:1: Error: Content is not allowed in prolog.
If i clean the project, then add image and run the app, it runs properly but the image is not displayed saying: FileNotFound.
I have tried the solutions posted online like taking into consideration (assets and asset, etc).
Upvotes: 0
Views: 2008
Reputation: 316
Well it turns out to be a android studio problem. If you close and reopen android studio, you can successfully refer to the image. I also tried inserting more images. Only after I re-open studio, I was able to use them. Thanks for the help!
Upvotes: 0
Reputation: 480
Did you try moving the files to the raw folder? You can then reference them by using the R class. Otherwise, you can try moving the file to "src/main/assets" and then map the custom path in your build.gradle file like:
android {
sourceSets {
main {
assets.srcDirs = ['src/main/assets/']
}
}
}
Upvotes: 0