4

I'm pretty new to android development, so I hope my question is easy, but not completely stupid. I'm using Eclipse to build an android application. It is based on the barcode-scanner of the ingenious guys from zxing. I already did quite some changes to the original code and everything works fine. But I still have the problem, that the original barcode-scanner and my app cannot run simultaneously on one mobile device. As far as I could find out, the problem is the package name. So I tried to change it to something else. But that srew up my entire project, because I can't access my resources anymore (e.g. findViewById(R.id.btDone); <-- R cannot be resolved to a variable).

Can anyone tell me what else I have to change to make my code work again?

This the beginning of my AndroidManifest.xml where I tried to change the package name:

<manifest
  xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.google.zxing.client.android"
  ...

I also found an interesting entry in build.properties: (?!)

application-package=com.google.zxing.client.android

Thanks you guys!

Thassilo
  • 309
  • 1
  • 4
  • 12
  • 3
    We strongly discourage people from starting by copying our code for Barcode Scanner. Not really cool. – Sean Owen Jan 24 '12 at 20:31
  • 1
    Hm ... how should I use the code instead? I don't want to force the user to install the barcode app separately. My intention is definitely not to claim authorship of the original code or infringe any copyrights! – Thassilo Jan 24 '12 at 21:34
  • 2
    Of course you may not want the third-party dependency: so you should write your own scanner app, then use the core library for decoding. You can reuse parts of Barcode Scanner as needed. What we don't like to see is starting from copy and paste, as the final result ends up staying 90% copy and paste in too many cases, and that doesn't seem right even if it's technically legal. Maybe you're really innovating on the app but most who do this aren't. – Sean Owen Jan 24 '12 at 22:54

3 Answers3

14

This should do it: Right Click on project -> Android Tools -> Rename Application Package

Scalarr
  • 746
  • 7
  • 26
0

Android - Package Name convention

The package refers to the file directory you made. If you still have problems, especially with android, sometimes doing project->clean and then rebuilding fixes some of the linking problems with resources

Community
  • 1
  • 1
Benoir
  • 1,244
  • 10
  • 10
-1

Assuming you choose to go with the new package name:

com.superscanner.android

And with the old package name being (for example):

com.google.zxing.client.android

Go through all the source code and change:

import com.google.zxing.client.android.R;

To:

import com.superscanner.android.R;

You'll also have to rename all your directories to match your new package structure, and change your import and package statements throughout, but this should get you going.

Marvin Pinto
  • 30,138
  • 7
  • 37
  • 54