简体   繁体   中英

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 (eg 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!

这应该这样做:右键单击项目 - > Android工具 - >重命名应用程序包

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM