J'ai suivi le guide this pour apprendre à utiliser une activité Web de confiance. Très bien, mais la barre d'adresse apparaît toujours. Au début, je pense que c'était parce que lorsque l'application cherchait assetlinks.json la réponse était 404. Corrigé, mais pas de chance pour supprimer la barre d'adresse. Suis-je en train de manquer quelque chose?
Version Chrome: 72.0.3626.96
Version Android: 7.1.2 (LineageOS 14.1)
assetlinks.json
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "Android_app", "package_name": "com.example.twa_test",
"sha256_cert_fingerprints": ["2A:32:7D:B7:4D:0B:A5:6A:72:47:86:A3:2F:A6:BB:D8:26:DE:AB:7E:8B:EA:C7:16:80:EA:C3:F1:50:E7:8E:D1"] }
}]
AndroidManifest.xml
<manifest xmlns:Android="http://schemas.Android.com/apk/res/Android"
package="com.example.twa_test">
<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">
<meta-data
Android:name="asset_statements"
Android:resource="@string/asset_statements" />
<activity Android:name="Android.support.customtabs.trusted.LauncherActivity">
<!-- Edit Android:value to change the url opened by the TWA -->
<meta-data
Android:name="Android.support.customtabs.trusted.DEFAULT_URL"
Android:value="https://slexom.gitlab.io/namya/" />
<!-- This intent-filter adds the TWA to the Android Launcher -->
<intent-filter>
<action Android:name="Android.intent.action.MAIN" />
<category Android:name="Android.intent.category.LAUNCHER" />
</intent-filter>
<!--
This intent-filter allows the TWA to handle Intents to open
airhorner.com.
-->
<intent-filter>
<action Android:name="Android.intent.action.VIEW" />
<category Android:name="Android.intent.category.DEFAULT" />
<category Android:name="Android.intent.category.BROWSABLE" />
<!-- Edit Android:Host to handle links to the target URL-->
<data
Android:scheme="https"
Android:Host="slexom.gitlab.io/namya/" />
</intent-filter>
</activity>
</application>
</manifest>
res/values / strings.xml
<resources>
<string name="app_name">Namya</string>
<string name="asset_statements">
[{
\"relation\": [\"delegate_permission/common.handle_all_urls\"],
\"target\": {
\"namespace\": \"web\",
\"site\": \"https://slexom.gitlab.io/namya/\"}
}]
</string>
</resources>
build.gradle (Projet)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.Android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module: app)
apply plugin: 'com.Android.application'
Android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.twa_test"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "Android.support.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 'com.Android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.Android.support.test:runner:1.0.2'
androidTestImplementation 'com.Android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.GoogleChrome.custom-tabs-client:customtabs:3a71a75c9f'
}
Logcat
2019-02-08 18:19:01.918 10880-10880/? I/art: Late-enabling -Xcheck:jni
2019-02-08 18:19:02.352 10880-10880/com.example.twa_test W/System:
ClassLoader referenced unknown path: /data/app/com.example.twa_test-1/lib/arm
2019-02-08 18:19:02.403 10880-10880/com.example.twa_test I/InstantRun:
starting instant run server: is main process
2019-02-08 18:19:02.478 10880-10896/com.example.twa_test D/libEGL: loaded /system/lib/egl/libEGL_mali.so
2019-02-08 18:19:02.510 10880-10896/com.example.twa_test D/libEGL: loaded /system/lib/egl/libGLESv1_CM_mali.so
2019-02-08 18:19:02.660 10880-10880/com.example.twa_test W/art: Before Android 4.1, method Android.graphics.PorterDuffColorFilter Android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(Android.graphics.PorterDuffColorFilter, Android.content.res.ColorStateList, Android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in Android.graphics.drawable.Drawable
2019-02-08 18:19:02.727 10880-10896/com.example.twa_test D/libEGL: loaded /system/lib/egl/libGLESv2_mali.so
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: Rejecting re-init on previously-failed class Java.lang.Class<Android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: Java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.support.v4.view.ViewCompat.setBackground(Android.view.View, Android.graphics.drawable.Drawable) (ViewCompat.Java:2341)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.support.v7.widget.ActionBarContainer.<init>(Android.content.Context, Android.util.AttributeSet) (ActionBarContainer.Java:62)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Java.lang.Object Java.lang.reflect.Constructor.newInstance0!(Java.lang.Object[]) (Constructor.Java:-2)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Java.lang.Object Java.lang.reflect.Constructor.newInstance(Java.lang.Object[]) (Constructor.Java:430)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.createView(Java.lang.String, Java.lang.String, Android.util.AttributeSet) (LayoutInflater.Java:645)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.createViewFromTag(Android.view.View, Java.lang.String, Android.content.Context, Android.util.AttributeSet, boolean) (LayoutInflater.Java:787)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.createViewFromTag(Android.view.View, Java.lang.String, Android.content.Context, Android.util.AttributeSet) (LayoutInflater.Java:727)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, Android.view.View, Android.content.Context, Android.util.AttributeSet, boolean) (LayoutInflater.Java:858)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, Android.view.View, Android.util.AttributeSet, boolean) (LayoutInflater.Java:821)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, Android.view.ViewGroup, boolean) (LayoutInflater.Java:518)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.inflate(int, Android.view.ViewGroup, boolean) (LayoutInflater.Java:426)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.inflate(int, Android.view.ViewGroup) (LayoutInflater.Java:377)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Android.view.ViewGroup Android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.Java:607)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.Java:518)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.support.v7.app.AppCompatDelegateImpl.onPostCreate(Android.os.Bundle) (AppCompatDelegateImpl.Java:299)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.support.v7.app.AppCompatActivity.onPostCreate(Android.os.Bundle) (AppCompatActivity.Java:98)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.app.Instrumentation.callActivityOnPostCreate(Android.app.Activity, Android.os.Bundle) (Instrumentation.Java:1200)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Android.app.Activity Android.app.ActivityThread.performLaunchActivity(Android.app.ActivityThread$ActivityClientRecord, Android.content.Intent) (ActivityThread.Java:2666)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.app.ActivityThread.handleLaunchActivity(Android.app.ActivityThread$ActivityClientRecord, Android.content.Intent, Java.lang.String) (ActivityThread.Java:2751)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.app.ActivityThread.-wrap12(Android.app.ActivityThread, Android.app.ActivityThread$ActivityClientRecord, Android.content.Intent, Java.lang.String) (ActivityThread.Java:-1)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.app.ActivityThread$H.handleMessage(Android.os.Message) (ActivityThread.Java:1496)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.os.Handler.dispatchMessage(Android.os.Message) (Handler.Java:102)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.os.Looper.loop() (Looper.Java:154)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void Android.app.ActivityThread.main(Java.lang.String[]) (ActivityThread.Java:6186)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at Java.lang.Object Java.lang.reflect.Method.invoke!(Java.lang.Object, Java.lang.Object[]) (Method.Java:-2)
2019-02-08 18:19:02.920 10880-10880/com.example.twa_test I/art: at void com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.Java:889)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void com.Android.internal.os.ZygoteInit.main(Java.lang.String[]) (ZygoteInit.Java:779)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: Caused by: Java.lang.ClassNotFoundException: Didn't find class "Android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[Zip file "/data/app/com.example.twa_test-1/base.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_dependencies_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_0_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_1_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_2_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_3_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_4_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_5_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_6_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_7_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_8_apk.apk", Zip file "/data/app/com.example.twa_test-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.tw
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Java.lang.Class dalvik.system.BaseDexClassLoader.findClass(Java.lang.String) (BaseDexClassLoader.Java:56)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Java.lang.Class Java.lang.ClassLoader.loadClass(Java.lang.String, boolean) (ClassLoader.Java:380)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Java.lang.Class Java.lang.ClassLoader.loadClass(Java.lang.String) (ClassLoader.Java:312)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.support.v4.view.ViewCompat.setBackground(Android.view.View, Android.graphics.drawable.Drawable) (ViewCompat.Java:2341)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.support.v7.widget.ActionBarContainer.<init>(Android.content.Context, Android.util.AttributeSet) (ActionBarContainer.Java:62)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Java.lang.Object Java.lang.reflect.Constructor.newInstance0!(Java.lang.Object[]) (Constructor.Java:-2)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Java.lang.Object Java.lang.reflect.Constructor.newInstance(Java.lang.Object[]) (Constructor.Java:430)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.createView(Java.lang.String, Java.lang.String, Android.util.AttributeSet) (LayoutInflater.Java:645)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.createViewFromTag(Android.view.View, Java.lang.String, Android.content.Context, Android.util.AttributeSet, boolean) (LayoutInflater.Java:787)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.createViewFromTag(Android.view.View, Java.lang.String, Android.content.Context, Android.util.AttributeSet) (LayoutInflater.Java:727)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, Android.view.View, Android.content.Context, Android.util.AttributeSet, boolean) (LayoutInflater.Java:858)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, Android.view.View, Android.util.AttributeSet, boolean) (LayoutInflater.Java:821)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, Android.view.ViewGroup, boolean) (LayoutInflater.Java:518)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.inflate(int, Android.view.ViewGroup, boolean) (LayoutInflater.Java:426)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Android.view.View Android.view.LayoutInflater.inflate(int, Android.view.ViewGroup) (LayoutInflater.Java:377)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Android.view.ViewGroup Android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.Java:607)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.Java:518)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.support.v7.app.AppCompatDelegateImpl.onPostCreate(Android.os.Bundle) (AppCompatDelegateImpl.Java:299)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.support.v7.app.AppCompatActivity.onPostCreate(Android.os.Bundle) (AppCompatActivity.Java:98)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.app.Instrumentation.callActivityOnPostCreate(Android.app.Activity, Android.os.Bundle) (Instrumentation.Java:1200)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Android.app.Activity Android.app.ActivityThread.performLaunchActivity(Android.app.ActivityThread$ActivityClientRecord, Android.content.Intent) (ActivityThread.Java:2666)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.app.ActivityThread.handleLaunchActivity(Android.app.ActivityThread$ActivityClientRecord, Android.content.Intent, Java.lang.String) (ActivityThread.Java:2751)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.app.ActivityThread.-wrap12(Android.app.ActivityThread, Android.app.ActivityThread$ActivityClientRecord, Android.content.Intent, Java.lang.String) (ActivityThread.Java:-1)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.app.ActivityThread$H.handleMessage(Android.os.Message) (ActivityThread.Java:1496)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.os.Handler.dispatchMessage(Android.os.Message) (Handler.Java:102)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.os.Looper.loop() (Looper.Java:154)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void Android.app.ActivityThread.main(Java.lang.String[]) (ActivityThread.Java:6186)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at Java.lang.Object Java.lang.reflect.Method.invoke!(Java.lang.Object, Java.lang.Object[]) (Method.Java:-2)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.Java:889)
2019-02-08 18:19:02.921 10880-10880/com.example.twa_test I/art: at void com.Android.internal.os.ZygoteInit.main(Java.lang.String[]) (ZygoteInit.Java:779)
2019-02-08 18:19:03.284 10880-10880/com.example.twa_test D/LauncherActivity: Using URL from Manifest (https://slexom.gitlab.io/namya/).
2019-02-08 18:19:03.284 10880-10880/com.example.twa_test D/LauncherActivity: Launching Trusted Web Activity.
2019-02-08 18:19:03.470 10880-10923/com.example.twa_test I/Mali: Mali API Version : 401
2019-02-08 18:19:03.470 10880-10923/com.example.twa_test I/Mali: Mali REVISION: Linux-r4p0-00rel0 BUILD_DATE: 2014-11-10 20:23:11
2019-02-08 18:19:03.477 10880-10923/com.example.twa_test I/OpenGLRenderer: Initialized EGL, version 1.4
2019-02-08 18:19:03.477 10880-10923/com.example.twa_test D/OpenGLRenderer: Swap behavior 1
2019-02-08 18:19:03.598 10880-10880/com.example.twa_test W/art: Before Android 4.1, method int Android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in Android.widget.ListView
La même histoire, assetlinks.json valide avec succès, mais la barre d'URL existe, indique que SHA-256 de la console Google Play ne fonctionne pas
Pour ceux qui sont toujours confrontés à ce problème, probablement dans le fichier assetlinks.json, vous utilisez SHA256 à partir du "Certificat de téléchargement" et non du "Certificat de signature d'application". Vous pouvez trouver les deux certificats dans la console Google Play -> Gestion des versions -> Signature d'application.