4

I'm attempting to get my PWA app working using the Google TWA guide here:

https://developers.google.com/web/updates/2019/02/using-twa

I've followed the guide completely from start to finish multiple times, but can't seem to get it to hide the URL bar at any point.

I have uploaded the apk(release) to Google Play Console, and allowed it to do the signing for me.

I've gone through basically all of the questions on SO, and none of the solutions seem to work for me, or I already have them set up correctly.

Things to note that I have tried and checked:

  • I've copied the SHA256 fingerprint to my assetlinks.json file that was provided to me by the Play Console. Didn't work.
  • I've used the manually generated SHA256 fingerprint that I set up in Android Studio in my assetlinks.json. Didn't work.
  • Under both of the above conditions, I have tried manually loading the generated apk onto my phone instead of the apk from the Play Console. Didn't work.
  • I've tried using Android Studio to install the app using developer mode with USB debugging on my phone (tried both release and debug flavours). Also didn't work.
  • Tried changing the namespace in the strings.xml to "android_app" to match the namespace in the assetlinks.json file as a bit of a long shot. Didn't work.
  • Confirmed that the assetlinks.json file works using the asset links generator: https://developers.google.com/digital-asset-links/tools/generator
  • My assetlinks.json path is /.well-known/assetlinks.json
  • My intents seem to work (clicking a link in Google search results will prompt to launch the app, and the association stays)

My build.gradle (Module)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.mypwadomain.www"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 3
        versionName "0.1.9"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.github.GoogleChrome.custom-tabs-client:customtabs:d08e93fce3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

My AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.mypwadomain.www">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="PWAAppName"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="GoogleAppIndexingWarning">
        <meta-data
            android:name="asset_statements"
            android:resource="@string/asset_statements" />
        <activity
            android:name="android.support.customtabs.trusted.LauncherActivity">

            <meta-data
                android:name="android.support.customtabs.trusted.DEFAULT_URL"
                android:value="https://www.mypwadomain.com/login" />

            <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="www.mypwadomain.com"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

My strings.xml

<resources>
    <string name="app_name">PWAAppName</string>
    <string name="asset_statements">
        [{
            \"relation\": [\"delegate_permission/common.handle_all_urls\"],
            \"target\": {
                \"namespace\": \"web\",
                \"site\": \"https://www.mypwadomain.com\"}
        }]
    </string>
</resources>

My assetlinks.json

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "web",
    "site": "https://www.mypwadomain.com"
  }
},{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target" : { "namespace": "android_app", "package_name": "com.mypwadomain.www",
    "sha256_cert_fingerprints": ["...Google Signed Fingerprint..."] }
}]

The Audit in Lighthouse for the app itself comes back as 100 PWA compatibility, and adding to homescreen works well on both Android and iOS devices.

I'm pretty new to this. I'm primarily a PHP developer, and the actual app is working fine. I literally installed Android Studio for the first time a few days ago. On the plus side, I use PHPStorm, which is also made by JetBrains, so that part helped with the learning curve.

Any help or advice on what else I can check would be greatly appreciated.

EDIT: I loaded logcat via android studio (I am working on Windows). I then ran the app in debug mode, and the resulting log is below. No instances of OriginVerifier or digital_asset_links

2019-06-20 11:18:12.440 12042-12042/? E/Zygote: accessInfo : 1
2019-06-20 11:18:12.444 12042-12042/? I/SELinux: SELinux: seapp_context_lookup: seinfo=default, level=s0:c94,c257,c512,c768, pkgname=com.mypwaapp.www 
2019-06-20 11:18:12.453 12042-12042/? I/m.mypwaapp.ww: Late-enabling -Xcheck:jni
2019-06-20 11:18:12.609 12042-12042/com.mypwaapp.www W/ActivityThread: Application com.mypwaapp.www is waiting for the debugger on port 8100...
2019-06-20 11:18:12.610 12042-12042/com.mypwaapp.www I/System.out: Sending WAIT chunk
2019-06-20 11:18:13.814 12042-12042/com.mypwaapp.www I/System.out: Debugger has connected
2019-06-20 11:18:13.815 12042-12042/com.mypwaapp.www I/System.out: waiting for debugger to settle...
2019-06-20 11:18:14.017 12042-12042/com.mypwaapp.www I/chatty: uid=10350(com.mypwaapp.www) identical 1 line
2019-06-20 11:18:14.220 12042-12042/com.mypwaapp.www I/System.out: waiting for debugger to settle...
2019-06-20 11:18:14.423 12042-12042/com.mypwaapp.www I/System.out: waiting for debugger to settle...
2019-06-20 11:18:14.625 12042-12042/com.mypwaapp.www I/System.out: waiting for debugger to settle...
2019-06-20 11:18:14.828 12042-12042/com.mypwaapp.www I/System.out: waiting for debugger to settle...
2019-06-20 11:18:15.032 12042-12042/com.mypwaapp.www I/chatty: uid=10350(com.mypwaapp.www) identical 1 line
2019-06-20 11:18:15.235 12042-12042/com.mypwaapp.www I/System.out: waiting for debugger to settle...
2019-06-20 11:18:15.440 12042-12042/com.mypwaapp.www I/System.out: debugger has settled (1500)
2019-06-20 11:18:15.457 12042-12042/com.mypwaapp.www D/ConnectivityManager_URSP: Ursp sIsUrsp=false, sIsCheckUrsp=false, uid=10350
2019-06-20 11:18:15.478 12042-12042/com.mypwaapp.www D/Proxy: urspP is null: 10350
2019-06-20 11:18:15.788 12042-12042/com.mypwaapp.www W/m.mypwaapp.ww: JIT profile information will not be recorded: profile file does not exits.
2019-06-20 11:18:15.831 12042-12042/com.mypwaapp.www I/chatty: uid=10350(com.mypwaapp.www) identical 10 lines
2019-06-20 11:18:15.835 12042-12042/com.mypwaapp.www W/m.mypwaapp.ww: JIT profile information will not be recorded: profile file does not exits.
2019-06-20 11:18:15.948 12042-12042/com.mypwaapp.www I/InstantRun: starting instant run server: is main process
2019-06-20 11:18:16.101 12042-12063/com.mypwaapp.www D/libEGL: loaded /vendor/lib64/egl/libGLES_mali.so
2019-06-20 11:18:16.403 12042-12042/com.mypwaapp.www D/TWAProviderPicker: Found Custom Tabs provider: com.sec.android.app.sbrowser
2019-06-20 11:18:16.404 12042-12042/com.mypwaapp.www D/TWAProviderPicker: Found no TWA providers, using first Custom Tabs provider: com.sec.android.app.sbrowser
2019-06-20 11:18:16.410 12042-12042/com.mypwaapp.www D/TWALauncherActivity: Using URL from Manifest (https://www.mypwaapp.com/login).
2019-06-20 11:18:17.330 12042-12042/com.mypwaapp.www W/m.mypwaapp.ww: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
2019-06-20 11:18:17.335 12042-12042/com.mypwaapp.www W/m.mypwaapp.ww: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
2019-06-20 11:18:17.506 12042-12042/com.mypwaapp.www D/OpenGLRenderer: Skia GL Pipeline
2019-06-20 11:18:17.528 12042-12042/com.mypwaapp.www D/EmergencyMode: [EmergencyManager] android createPackageContext successful
2019-06-20 11:18:17.678 12042-12042/com.mypwaapp.www D/InputTransport: Input channel constructed: fd=81
2019-06-20 11:18:17.686 12042-12042/com.mypwaapp.www D/ViewRootImpl@c9324c2[LauncherActivity]: setView = DecorView@fe5f2d3[LauncherActivity] TM=true MM=false
2019-06-20 11:18:17.717 12042-12042/com.mypwaapp.www D/ViewRootImpl@c9324c2[LauncherActivity]: Surface release. android.view.WindowManagerGlobal.setStoppedState:669 android.app.Activity.performStop:7646 android.app.ActivityThread.callActivityOnStop:4352 android.app.ActivityThread.performStopActivityInner:4330 android.app.ActivityThread.handleStopActivity:4405 android.app.servertransaction.StopActivityItem.execute:41 android.app.servertransaction.TransactionExecutor.executeLifecycleState:145 android.app.servertransaction.TransactionExecutor.execute:70 
2019-06-20 11:18:17.779 12042-12042/com.mypwaapp.www D/ViewRootImpl@c9324c2[LauncherActivity]: dispatchAttachedToWindow
2019-06-20 11:18:17.839 12042-12042/com.mypwaapp.www D/ViewRootImpl@c9324c2[LauncherActivity]: Relayout returned: old=[0,0][1440,2960] new=[0,0][1440,2960] result=0x1 surface={valid=false 0} changed=false

EDIT 2: I did find this in the logcat feed:

2019-06-20 12:23:56.772 6226-11769/? I/SingleHostAsyncVerifier: Verification result: checking for a statement with source a: # bpti@709f0232
    w: 29
    , relation delegate_permission/common.handle_all_urls, and target b <
      a: "com.mypwaapp.www"
      b: # bptg@e7d522a2
      w: 118
    >
    w: 120
     --> false.

Not sure if relevant or not.

Incredibad
  • 51
  • 6
  • 1
    Can you run `adb logcat | grep -e OriginVerifier -e digital_asset_links`, open the TWA and post what is printed on the console? – andreban Jun 18 '19 at 20:43
  • Hi @andreban, thanks for the reply. I'm running on windows so I had to run logcat through studio. I've updated my post with the resulting log file (no instances of OriginVerifier or digital_asset_links). – Incredibad Jun 20 '19 at 01:24
  • 1
    Thanks. Would you be able to share the APK with me, so I can take a closer look on what is wrong? – andreban Jun 22 '19 at 07:43
  • https://drive.google.com/file/d/1vGMOSyz3atpkGGQq3xkXRmSdKEt8xLeL/view?usp=sharing – Incredibad Jun 23 '19 at 08:54
  • 1
    I installed the APK and texted on a Nexus 6P / Chrome 75, and it worked well. Can you provide more information on device / Chrome version combination? Also, if you have other browsers installed and which one is the default. – andreban Jun 24 '19 at 16:13
  • I actually feel really stupid and embarrassed right now. My default browser must have reset to the Samsung browser when I cleared out settings on my phone (Samsung Note 9) when I was troubleshooting the problem. I set the default browser to Chrome, and you're correct. It's working fine. Thank you so much. Sometimes it just takes someone else to look at it and everything is exposed. – Incredibad Jun 25 '19 at 04:26
  • Happy to help rubber ducking :). It'd be great if you could add this finding as an answer to the question. Other folks may run into the same problem. – andreban Jun 25 '19 at 17:28

2 Answers2

1

My default browser must have reset to the Samsung browser when I cleared out settings on my phone (Samsung Note 9) when I was troubleshooting the problem. I set the default browser to Chrome. It's working fine.

Thanks to andreban :)

Incredibad
  • 51
  • 6
-1

I had a similar case to @Incredibad, where I had both Chrome and Chrome Dev installed, with Chrome dev becoming the default browser.

Ben Brookes
  • 390
  • 2
  • 14