Android App Crash inicio - customtabs.CustomTabsSession.validateRelationship

GenesisBits:

He seguido las directrices Googles de las recientes actividades web de confianza y mi aplicación ha estado trabajando bien en mi dispositivo y seleccione algunos emuladores.

Sin embargo, en ciertos dispositivos y emuladores (como Google Pixel 2) me sale un accidente de inmediato en el inicio.

Las salidas LogCat:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ocdev.yu_gi_ohdatabase, PID: 5020
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.support.customtabs.CustomTabsSession.validateRelationship(int, android.net.Uri, android.os.Bundle)' on a null object reference
        at android.support.customtabs.TrustedWebUtils.launchAsTrustedWebActivity(TrustedWebUtils.java:134)
        at android.support.customtabs.trusted.LauncherActivity$TwaCustomTabsServiceConnection.onCustomTabsServiceConnected(LauncherActivity.java:199)
        at android.support.customtabs.CustomTabsServiceConnection.onServiceConnected(CustomTabsServiceConnection.java:44)
        at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1634)
        at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1663)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ocdev.yu_gi_ohdatabase">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ygo_fore"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ygo_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://db.ygoprodeck.com" />

            <!-- 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="db.ygoprodeck.com"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

build.gradle módulo:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.ocdev.yu_gi_ohdatabase"
        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'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:animated-vector-drawable:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
}

build.gradle Proyecto:

// 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
}

También he probado mi apk lanzamiento en emuladores de Android a través de Browserstack y recibo el mismo problema exacto. También he recibido el tema en algunos dispositivos físicos pruebo como Samsung Galaxy S7 Edge pero lo extraño es que he probado un Galaxy S7 Edge diferente y funcionó sin problemas. Por lo que he probado hasta ahora, supongo que funciona en el 50% de los dispositivos que he probado. No soy un desarrollador de Android hereda así que estoy luchando para encontrar la causa de este problema y por qué funciona bien y algunos dispositivos y no en otros.

GenesisBits:

He publicado esta pregunta en los foros de cromo y obtuve redirigido a una solución temporal que aparece aquí .

En resumen, son conscientes del problema y la esperanza de tener una solución permanente a cabo en breve por lo que la solución temporal, no se necesita mucho tiempo.

La respuesta dada:

Por el momento, puede cambiar el último parámetro a CustomTabsClient # getPackageName aquí en true. Este parámetro es 'ignoreDefault' y, como es fácil adivinar hará la selección de paquetes ignorar por defecto del usuario. Lo ideal sería que aunque esto no será necesario por mucho tiempo.

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=180222&siteId=1
Recomendado
Clasificación