在Android项目中重命名包名称

时间:2013-10-30 11:16:04

标签: android eclipse

我无法在Android项目中重命名包名称。我正在使用Android工具/重命名应用程序包。我正在使用ndroid ADeveloper工具

构建:v22.2.1-833290

这是错误:

java.lang.reflect.InvocationTargetException
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
    at org.eclipse.ui.internal.WorkbenchWindow$13.run(WorkbenchWindow.java:1679)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:1676)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:663)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:502)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizard.getStartingPage(RefactoringWizard.java:472)
    at org.eclipse.jface.wizard.WizardDialog.showStartingPage(WizardDialog.java:1271)
    at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:610)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:178)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:202)
    at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:122)
    at com.android.ide.eclipse.adt.internal.refactorings.renamepackage.RenamePackageAction.initiateAndroidPackageRefactoring(RenamePackageAction.java:168)
    at com.android.ide.eclipse.adt.internal.refactorings.renamepackage.RenamePackageAction.promptNewName(RenamePackageAction.java:151)
    at com.android.ide.eclipse.adt.internal.refactorings.renamepackage.RenamePackageAction.run(RenamePackageAction.java:106)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    ............
    at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86)
    at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86)
    at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86)
    at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:127)
    at org.eclipse.core.internal.resources.Resource.accept(Resource.java:95)
    at org.eclipse.core.internal.resources.Resource.accept(Resource.java:52)
    at org.eclipse.core.internal.resources.Resource.accept(Resource.java:124)
    at org.eclipse.core.internal.resources.Resource.accept(Resource.java:108)
    at com.android.ide.eclipse.adt.internal.refactorings.renamepackage.ApplicationPackageNameRefactoring.createChange(ApplicationPackageNameRefactoring.java:126)
    at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:124)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
    at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

有任何帮助吗?谢谢

5 个答案:

答案 0 :(得分:3)

检查是否有任何课程被完全注释。如果是,请取消注释。

答案 1 :(得分:0)

更改清单

中的包名称
    package="com.example.appname"

答案 2 :(得分:0)

右键单击包文件夹选择Refector选择重命名.....欢呼

答案 3 :(得分:0)

检查您是否有空课。

答案 4 :(得分:0)

使用项目有一种解决方法 - > Android工具 - >重命名应用程序包

在示例中,我们将com.my.app重命名为com.my.newapp

在重新修订之前始终备份项目

  1. 扩展您的项目 - >根
  2. 右键单击com.my.app并选择Refactor,输入新名称com.my.newapp
  3. 将重命名和更新文件。将创建与旧名称匹配的包,暂时忽略它
  4. 打开AndroidManifest.xml并将包名称更改为com.my.newapp
  5. 从gen
  6. 中删除旧的com.my.app包
  7. 展开项目 - > SRC
  8. 右键单击com.my.app并重构为com.my.newapp(包含子类但不执行文本)
  9. 您的项目现在应该使用它的新软件包名称构建。您现在可以更新对com.my.newapp的任何文本引用,检查完整的AndroidManifest.xml以获取更新的任何其他内容。