eclipse 如何正确更改 AndroidManifest.xml 中的包名(例如在项目 zxing/barcodescanner 中)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8993517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to properly change the package name in AndroidManifest.xml (e.g. in project zxing/barcodescanner)
提问by Thassilo
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).
我对 android 开发很陌生,所以我希望我的问题很简单,但不是完全愚蠢。我正在使用 Eclipse 构建一个 android 应用程序。它基于 zxing 聪明人的条形码扫描仪。我已经对原始代码进行了一些更改,并且一切正常。但我仍然遇到问题,原始条码扫描器和我的应用程序无法在一台移动设备上同时运行。据我所知,问题是包名。所以我试着把它改成别的东西。但这破坏了我的整个项目,因为我无法再访问我的资源(例如 findViewById(R.id.btDone); <-- R 无法解析为变量)。
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:
这是我尝试更改包名称的 AndroidManifest.xml 的开头:
<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: (?!)
我还在 build.properties 中发现了一个有趣的条目:(?!)
application-package=com.google.zxing.client.android
Thanks you guys!
谢谢你们!
回答by Scalarr
This should do it: Right Click on project -> Android Tools -> Rename Application Package
应该这样做:右键单击项目 -> Android 工具 -> 重命名应用程序包
回答by Bentheitroad
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
包是指您创建的文件目录。如果你仍然有问题,尤其是 android,有时做 project->clean 然后重建修复一些与资源的链接问题
回答by Marvin Pinto
Assuming you choose to go with the newpackage name:
假设您选择使用新的包名称:
com.superscanner.android
And with the oldpackage 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.
您还必须重命名所有目录以匹配您的新包结构,并在整个过程中更改您的import
andpackage
语句,但这应该可以帮助您前进。