Android - put an image name "package" throws compile time error
Asked Answered
G

1

8

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".

Grimbald answered 26/5, 2012 at 7:7 Comment(0)
S
14

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)
Seashore answered 26/5, 2012 at 7:16 Comment(1)
The Java documentation.Layer

© 2022 - 2024 — McMap. All rights reserved.