Home » Android » drawable – Android – put an image name "package" throws compile time error

drawable – Android – put an image name "package" throws compile time error

Posted by: admin June 15, 2020 Leave a comment

Questions:

I am trying to put an image name “package.png” in my drawable folder. As soon as i paste them it into the folder it is throwing following error:

[2012-05-26 12:40:30 - MyApp] res/drawable-mdpi/package.png:0: error: invalid symbol: 'package'

But as soon as i rename to some other name, this image works fine. Any idea why this is happening and how i can fix this and have a drawable named “package”.

How to&Answers:

you cant do that, as it is a Reserved word. just like…

break else new var
case finally return void
catch for switch while
continue function this with
default if throw
delete in try
do instanceof typeof
abstract enum int short
boolean export interface static
byte extends long super
char final native synchronized
class float package throws
const goto private transient
debugger implements protected volatile
double import public
null
true
false

Each resource having entry in java field name inside R.java class:

drawable\package.png -> R.drawable.package // while package is a reserved keyword in Java(mentioned above)