0

---编辑---
忘记包含原始清单。这里是:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.web.scratch_v2">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name="android.support.customtabs.trusted.LauncherActivity"
            android:label="${launcherName}">

            <meta-data
                android:name="android.support.customtabs.trusted.DEFAULT_URL"
                android:value="${defaultUrl}"/>


            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>


            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data
                    android:scheme="https"
                    android:host="${hostName}"/>
            </intent-filter>
        </activity>
        <meta-data
            android:name="asset_statements"
            android:value="${assetStatements}" />
    </application>
</manifest>

原帖:

我对 android dev 非常陌生,但目前正在尝试通过受信任的 Web 活动将我的 PWA 打包为 APK。

我在哪里:
- 应用程序在模拟设备上安装和运行
- 它在 TWA 中运行,而不是作为自定义选项卡。但是,在生成签名的 APK 后

问题:
- 当我分析生成的 APK 时,我收到错误“运行应用程序发布时出错,未找到默认活动”。

我的评价:

问题似乎出在已签名的 apk 进程生成的清单中,这就是清单。我正在构建的项目的清单中不存在一些命名空间错误,以及活动中未解决的包(customtabs)。以下是生成的签名 APK 的清单(此 APK 输出到与项目不同的目录中):

    <?xml version="1.0" encoding="utf-8"?><manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName="1.0"
    android:compileSdkVersion="29"
    android:compileSdkVersionCodename="10"
    package="app.web.scratch_v2"
    platformBuildVersionCode="29"
    platformBuildVersionName="10">

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="29" />

    <application
        android:theme="@ref/0x7f0d0005"
        android:label="@ref/0x7f0c001b"
        android:icon="@ref/0x7f0b0000"
        android:allowBackup="true"
        android:supportsRtl="true"
        android:roundIcon="@ref/0x7f0b0001"
        android:appComponentFactory="androidx.core.app.CoreComponentFactory">

        <activity
            android:label="my-name"
            android:name="android.support.customtabs.trusted.LauncherActivity">

            <meta-data
                android:name="android.support.customtabs.trusted.DEFAULT_URL"
                android:value="my-url" />

            <intent-filter>

                <action
                    android:name="android.intent.action.MAIN" />

                <category
                    android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter
                android:autoVerify="true">

                <action
                    android:name="android.intent.action.VIEW" />

                <category
                    android:name="android.intent.category.DEFAULT" />

                <category
                    android:name="android.intent.category.BROWSABLE" />

                <data
                    android:scheme="https"
                    android:host="my-host-here" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="asset_statements"
            android:value="[{ "relation": ["delegate_permission/common.handle_all_urls"], "target": {"namespace": "web", "site": "https://my-link-here/"}}]" />
    </application>
</manifest>

但是,当我用“/app/build/intermediates/bundle_manifest/release/bundle-manifest/AndroidManifest.xml”(来自同一个项目)中的清单替换该清单路径时,一切都已修复,并且 APK 运行良好。这是清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.web.scratch_v2"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="29" />

    <application
        android:allowBackup="true"
        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:testOnly="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name="android.support.customtabs.trusted.LauncherActivity"
            android:label="my-name" >
            <meta-data
                android:name="android.support.customtabs.trusted.DEFAULT_URL"
                android:value="my-url" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter android:autoVerify="true" >
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="my-host-here"
                    android:scheme="https" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="asset_statements"
            android:value="[{ "relation": ["delegate_permission/common.handle_all_urls"], "target": {"namespace": "web", "site": "https://my-link-here/"}}]" />
    </application>

</manifest>

所以,我确定是我的项目中的糟糕配置导致了这一点,但我找不到错误。任何建议表示赞赏!

4

0 回答 0