Android:包括多个要清单的 Java 包

Android: Including multiple Java Packages to Manifest(Android:包括多个要清单的 Java 包)
本文介绍了Android:包括多个要清单的 Java 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在开发的应用程序有许多活动,这些活动组织成七个 java 包.最初,我将 java 包中每组活动的所有编码和内容编写为不同的项目.

The app I am developing has many activities organized into seven java packages. Originally I wrote all the coding and stuff for each group of activities in a java package as different projects.

现在我想将所有包放在一个项目中.当我将新包添加到 src 文件夹时,我的所有 R.id.* 值都会出现错误(R 无法解析").

Now I'm at the point where I want to put all the packages together into one project. When I add a new package to the src folder, I get an error for all my R.id.* values ("R cannot be resolved").

我的直觉告诉我,我必须在项目清单中添加一些花哨的东西,但我在网上找不到任何资源来告诉我如何操作.

My instinct tells me that there is something fancy I have to put in the project manifest, but I can't find any resource online to tell me how.

(注意:我已阅读 this 和 this 我仍然不知道如何向我的项目添加额外的包.)

(Note: I have read this and this and I still couldn't figure out how to add additional packages to my project.)

推荐答案

确保 Activity 顶部的 import 语句引用了正确的 R 文件.每个项目都有自己的 R 文件,因此如果您将 Activity 从一个项目复制到另一个项目,它仍会尝试从旧项目中引用 R 文件.

Make sure that the import statement at the top of the Activity references the correct R file. Each project has its own R file, so if you copy an Activity from one project to another it will still be trying to reference the R file from the old project.

您不需要在清单中明确包含不同的包.要包含来自两个不同包的活动,请说:

You do not need any explicit inclusion of different packages in the manifest. To include activities from two different packages, say:

com.example.package1.Activity1
com.example.package2.Activity2

您可以执行以下操作:

<manifest package="com.example" . . . >
  <application . . .>
    <activity android:name=".package1.Activity1" . . . />
    <activity android:name=".package2.Activity2" . . . />
  </application>
</manifest>

这篇关于Android:包括多个要清单的 Java 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
cocos2d-android: how to display score(cocos2d-android:如何显示分数)
Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
Android file copy(安卓文件拷贝)
Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)