GoogleChromeLabs / svgomg-twa

A sample that project Trusted Web Activities technology to wrap SVGOMG in an Android Application
Apache License 2.0
519 stars 132 forks source link

instant support #85

Closed nodabladam closed 4 years ago

nodabladam commented 4 years ago

When I try and add the following to enable instant support:

<manifest xmlns:dist="http://schemas.android.com/apk/distribution"
    ... >
    <dist:module dist:instant="true" />
    ...

~ https://developer.android.com/guide/app-bundle/instant-delivery

I get a immediate crash and stack trace "Unable to start activity...No Activity found to handle Intent". My guess is that it is something to do with the splash screen...I can't seem to figure out how to copy exact stack trace but it is easy to reproduce...just check the "Deploy as instant app" to the "Run/Debug Configuration"

Can you please update svgomg-twa manifest to support instant?

andreban commented 4 years ago

TWAs don't currently work with instant apps - they are unable to remove the address bar.

Having said that, I don't think the application itself should be crashing - It should work, but with the address bar visible. Would you mind post the entire AndroidManifest.xml, so I can have a better idea on what may be happening?

nodabladam commented 4 years ago

Ok, thank you for your advice. I won't worry about getting instant working if can't remove the address bar.

I started with the manifest from here and made these changes:

summary

<manifest ...
    xmlns:dist="http://schemas.android.com/apk/distribution"
    ... >

    <dist:module dist:instant="true" />
   ...

                <data android:host="@string/hostName" android:scheme="https" />
                <data android:host="@string/hostName" android:scheme="http" />

            </intent-filter>

            <meta-data android:name="default-url" android:value="https://nodabl.co/app/home" />

Full

<!--
    Copyright 2019 Google Inc. All Rights Reserved.

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- The "package" attribute is rewritten by the Gradle build with the value of applicationId.
     It is still required here, as it is used to derive paths, for instance when referring
     to an Activity by ".MyActivity" instead of the full name. If more Activities are added to the
     application, the package attribute will need to reflect the correct path in order to use
     the abbreviated format. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    package="nodabl.co.pwa">

    <dist:module dist:instant="true" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/appName"
        android:supportsRtl="true"
        android:theme="@style/Theme.LauncherActivity">

        <meta-data
            android:name="asset_statements"
            android:resource="@string/assetStatements" />
        <meta-data
            android:name="cros_web_alternative"
            android:value="@string/crosLaunchUrl" />

        <activity
            android:name="com.google.androidbrowserhelper.trusted.LauncherActivity"
            android:label="@string/appName">
            <meta-data
                android:name="android.support.customtabs.trusted.DEFAULT_URL"
                android:value="@string/launchUrl" />

            <meta-data
                android:name="android.support.customtabs.trusted.STATUS_BAR_COLOR"
                android:resource="@color/colorPrimary" />

            <meta-data
                android:name="android.support.customtabs.trusted.NAVIGATION_BAR_COLOR"
                android:resource="@color/navigationColor" />

            <meta-data
                android:name="android.support.customtabs.trusted.SPLASH_IMAGE_DRAWABLE"
                android:resource="@drawable/screen" />

            <meta-data
                android:name="android.support.customtabs.trusted.SPLASH_SCREEN_BACKGROUND_COLOR"
                android:resource="@color/backgroundColor" />

            <meta-data
                android:name="android.support.customtabs.trusted.SPLASH_SCREEN_FADE_OUT_DURATION"
                android:value="@integer/splashScreenFadeOutDuration" />

            <meta-data
                android:name="android.support.customtabs.trusted.FILE_PROVIDER_AUTHORITY"
                android:value="@string/providerAuthority" />

            <meta-data
                android:name="android.app.shortcuts"
                android:resource="@xml/shortcuts" />

            <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="@string/hostName"
                    android:scheme="https" />

                <data
                    android:host="@string/hostName"
                    android:scheme="http" />
            </intent-filter>

            <meta-data
                android:name="default-url"
                android:value="https://nodabl.co/app/home" />

        </activity>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="@string/providerAuthority"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
        </provider>

        <service
            android:name="com.google.androidbrowserhelper.trusted.DelegationService"
            android:enabled="@bool/enableNotification"
            android:exported="@bool/enableNotification">

            <intent-filter>
                <action android:name="android.support.customtabs.trusted.TRUSTED_WEB_ACTIVITY_SERVICE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>

    </application>
</manifest>
PEConn commented 4 years ago

The issue with TWAs and Instant Apps isn't anything to do with Digital Asset Link verification. Essentially Instant Apps can only send explicit intents to Activities/Services that have visibleToInstantApps="true", which is not the case either for Chrome's Custom Tab Service or for its Launcher Activity.

There's a Chromium bug to track this here.

andreban commented 4 years ago

Closing the issue here in favour of tracking it in Chromium Bugs