Thassilo
Thassilo

Reputation: 309

How to properly change the package name in AndroidManifest.xml (e.g. in project zxing/barcodescanner)

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!

Upvotes: 4

Views: 11745

Answers (3)

Marvin Pinto
Marvin Pinto

Reputation: 31018

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.

Upvotes: -1

Scalarr
Scalarr

Reputation: 756

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

Upvotes: 14

Benoir
Benoir

Reputation: 1244

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

Upvotes: 0

Related Questions