Skip to content

research and add an APK or AndroidManifest.xml validator #8

@silbinarywolf

Description

@silbinarywolf

Edited (2024-10-01)

aapt2 add error checking for AndroidManifest.xml so the following PR changes this build SDK to use that.
#10

See:

Original Post

If you slightly mess up the XML in your AndroidManifest.xml file, you should ideally get an obvious compilation error.
For example, OpenXR wasn't working for me because I had failed to put a category within the intent filter.

Todo

Look into the apkanalyzer command line tool and invoke it testing the broken and then fixed version.
See: https://developer.android.com/studio/debug/apk-analyzer

Alternatively we could look at using the lint command here: https://developer.android.com/studio/write/lint.

Both of these commands exist in Android\Sdk\tools\bin

Broken/invalid XML

<activity android:name="HelloVRSDLActivity"
            android:label="@string/app_name"
            android:alwaysRetainTaskState="true"
            android:launchMode="singleInstance"
            android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
            android:preferMinimalPostProcessing="true"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />
            </intent-filter>

Correct valid XML

<activity android:name="HelloVRSDLActivity"
            android:label="@string/app_name"
            android:alwaysRetainTaskState="true"
            android:launchMode="singleInstance"
            android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
            android:preferMinimalPostProcessing="true"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions