当我跑
gradle lint
从项目目录或根目录我得到一大堆报告(对于每个活动和应用程序),比如
<issue
id="MissingRegistered"
severity="Error"
message="Class referenced in the manifest, com.mypackage.activities.MyActivity, was not found in the project or the libraries"
category="Correctness"
priority="8"
summary="Ensures that classes referenced in the manifest are present in the project or libraries"
explanation="If a class is referenced in the manifest, it must also exist in the project (or in one of the libraries included by the project. This check helps uncover typos in registration names, or attempts to rename or move classes without updating the manifest file properly."
url="http://developer.android.com/guide/topics/manifest/manifest-intro.html"
urls="http://developer.android.com/guide/topics/manifest/manifest-intro.html"
errorLine1=" <activity"
errorLine2=" ^">
<location
file="AndroidManifest.xml"
line="58"
column="9"/>
</issue>
我确定它们被正确引用,因为在构建之后
gradle build
或者
gradle assembleDebug
每个活动都可以启动。
如果这很重要,我的项目有一些子项目。
设置.gradle
include ':Lib1'
include ':Lib2'
include ':MainProject'
每个活动都列在 MainProject 的清单中,并且位于 MainProject 中。
MainProject/AndroidManifest.xml
包名和活动名称被替换,但通用包层次结构代表真正的层次结构。我还删除了一些活动,例如留下了两个。所有其他人都在同一个包中,并像上一个一样定义,只是名称不同。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.package"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="19" />
<application
android:name="com.my.package.subpackage.MyApp"
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:largeHeap="true"
android:hardwareAccelerated="true"
android:theme="@style/AppTheme" >
<activity
android:name="com.my.package.subpackage.activities.SplashActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="sensorLandscape"
android:configChanges="orientation|screenSize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.my.package.subpackage.activities.HelpActivity"
android:theme="@style/TransparentTheme"/>
</application>
</manifest>