TWA app crash because of java.lang.ClassNotFoundException: Didn't find class "androidx.browser.trusted.LauncherActivity"

15 Views Asked by At

I'm currently trying to make a TWA app from a web site I own.

First I created a no activity app with android studio, then imported the library "androidx.browser" in build.gradle.kts (Module:app) as follow:

dependencies {
    implementation("androidx.core:core-ktx:1.12.0")
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.11.0")
    implementation("androidx.browser:browser:1.4.0")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}

Then I try to use it in my AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyHappyApp">


      <activity
        android:name="androidx.browser.trusted.LauncherActivity"
        android:label="${launcherName}"
        android:exported="true">
        <meta-data
          android:name="androidx.browser.trusted.enabled"
          android:value="true" />
        <meta-data
          android:name="androidx.browser.trusted.enabled"
          android:value="${defaultUrl}"/>
        <meta-data
          android:name="asset_statements"
          android:value="${assetStatements}" />

        <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>
    </application>
</manifest>

When I try to launch the app the error is:

Process: io.workspace.myhappyapp, PID: 2865
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{io.workspace.myhappyapp/androidx.browser.trusted.LauncherActivity}: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.trusted.LauncherActivity" on path: DexPathList[[zip file "/data/app/~~qPB8YSyxaGQ3YH1bfIjgLQ==/io.workspace.myhappyapp-8C6zRzfJrUXQTvPThzh8Pw==/base.apk"],nativeLibraryDirectories=[/data/app/~~qPB8YSyxaGQ3YH1bfIjgLQ==/io.workspace.myhappyapp-8C6zRzfJrUXQTvPThzh8Pw==/lib/x86_64, /system/lib64, /system_ext/lib64]]
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3689)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:205)
    at android.os.Looper.loop(Looper.java:294)
    at android.app.ActivityThread.main(ActivityThread.java:8177)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.trusted.LauncherActivity" on path: DexPathList[[zip file "/data/app/~~qPB8YSyxaGQ3YH1bfIjgLQ==/io.workspace.myhappyapp-8C6zRzfJrUXQTvPThzh8Pw==/base.apk"],nativeLibraryDirectories=[/data/app/~~qPB8YSyxaGQ3YH1bfIjgLQ==/io.workspace.myhappyapp-8C6zRzfJrUXQTvPThzh8Pw==/lib/x86_64, /system/lib64, /system_ext/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
    at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:44)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1378)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3676)

Does anyone know what is the problem here?

Thank you for your time

0

There are 0 best solutions below