2

I am trying to create a trial version of an app i wrote. I copied my main project, then pasted it as a new project with a new name. I then refactored (appended Trial) to my activities, then i fixed any errors that cropped up because of this. Once the project compiled, I tried running the app.

When I try to run the trial app on the emulator, my app cannot find any of its resources (drawables, styles, etc) if I programatically access 'R.*'. If my app starts an activity that hard coded a style, that works fine (except the drawables are missing).

Also, I am not sure how resources are mapped, but when I open my generated R.java for each project they are identical! The errors thrown from my trial app say "Resource not found for xyz' and the id the exception shows me is different than the one in generated R.java.

Any one have any ideas how i can get this working?

Thanks.

*Addition** So I forgot to mention that I am targeting version Android 1.5 (api version 3). I just updated the target version to 4 and things worked... I would like to target 1.5 ... Anyone experience this? Thanks.

ekawas
  • 6,594
  • 3
  • 27
  • 39

2 Answers2

0

Look in the gen/ folder and see what package R.java is being generated in. All references to anything from R.java in your code must be either explicitly or implicitly to its actual current package name.

If R.java isn't being generated in the package you want, it can be tricky to convince eclipse to "move" it. What seems to work is making a copy of your primary java source file and renaming/relocating it to the package name you want R.java to be in, then deleting the original.

That plus a project clean and rebuild should get things working again.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
  • So the R is being generated into the correct package namespace. its the contents of R that seem to be incorrect. All source point to the correct R (i.e. the one that is generated by android) – ekawas Dec 07 '10 at 18:29
  • While this isn't the correct answer in my case, this should help most people (seeing as this is the advice given to most other people). Thanks Chris for attempting to help me. I ended up not supporting android 1.5 and now support 1.6+ in my app. – ekawas Jan 05 '11 at 22:22
0

For me, this is the best working solution i've found: Android - copy existing project with a new name

Seems like you first have to change the package name in manifest only, then your main package name (with refactor) and finally rename your application name in manifest.

Community
  • 1
  • 1
eyecatchUp
  • 10,032
  • 4
  • 55
  • 65