Fixed
Status Update
Comments
ed...@gmail.com <ed...@gmail.com> #2
In Backward Compatibility (pre Android 13), the configuration is modified at the AppComaptActivity's level and hence the application context not getting modified is intended behaviour. Similar behaviour can be seen for nightMode.
ki...@google.com <ki...@google.com> #3
Hope this solves the question, please re-open if more information is required.
ap...@google.com <ap...@google.com> #4
Why is this the intended behavior? Appcompatdelegate that works halfways?
Can someone clarify?
Can someone clarify?
ki...@google.com <ki...@google.com> #5
AppCompatDelegate generally works at the Activity level. This is the case with other features such as NightMode as well. This is why it is intended that it does not affect the application context.
I'm re-assigning this to the team to assess the feasibility of extending the feature to alter the application context.
Description
```
Android Studio 4.0 Beta 4
Build #AI-193.6911.18.40.6348893, built on March 30, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.4.30-1-MANJARO
GC: ParNew, ConcurrentMarkSweep
Memory: 1246M
Cores: 4
```
### Details of the issue:
When I build an app bundle with the following settings, I do not have the problem with
ClassNotFoundException for OnUnhandledKeyEventListener when running in the emulator or a device.
```
project.ext {
minSdkVersion = 21
compileSdkVersion = 29
buildToolsVersion = '29.0.3'
}
```
However, when running the app bundle, it shows the stacktrace error as an information message in Logcat.
_i.e. 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;_
Please advice what can be the possible cause, and provide a solution if any.
============================
### Stacktrace:
```
I/zygote: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
I/zygote: at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2474)
I/zygote: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:779)
I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:659)
I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(android.view.View) (AppCompatDelegateImpl.java:543)
I/zygote: at void androidx.appcompat.app.AppCompatActivity.setContentView(android.view.View) (AppCompatActivity.java:166)
I/zygote: at void ${application_package_id}.main.MainActivity.onCreate(android.os.Bundle) (MainActivity.kt:31)
I/zygote: at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:6999)
I/zygote: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6990)
I/zygote: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
I/zygote: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2731)
I/zygote: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2856)
I/zygote: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
I/zygote: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1589)
I/zygote: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
I/zygote: at void android.os.Looper.loop() (Looper.java:164)
I/zygote: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6494)
I/zygote: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/zygote: at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:440)
I/zygote: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:807)
I/zygote: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/${application_package_id}-Roo5KXtjcWX8GaOAqA9vFw==/base.apk", zip file "/data/app/${application_package_id}-Roo5KXtjcWX8GaOAqA9vFw==/split_${dynamic_module_03}.apk", zip file "/data/app/${application_package_id}-Roo5KXtjcWX8GaOAqA9vFw==/split_${dynamic_module_02}.apk", zip file "/data/app/${application_package_id}-Roo5KXtjcWX8GaOAqA9vFw==/split_${dynamic_module_01}.apk"],nativeLibraryDirectories=[/data/app/${application_package_id}-Roo5KXtjcWX8GaOAqA9vFw==/lib/arm, /system/lib, /system/vendor/lib]]
I/zygote: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125)
I/zygote: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
I/zygote: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
I/zygote: at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2474)
I/zygote: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:779)
I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:659)
I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(android.view.View) (AppCompatDelegateImpl.java:543)
I/zygote: at void androidx.appcompat.app.AppCompatActivity.setContentView(android.view.View) (AppCompatActivity.java:166)
I/zygote: at void ${application_package_id}.main.MainActivity.onCreate(android.os.Bundle) (MainActivity.kt:31)
I/zygote: at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:6999)
I/zygote: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6990)
I/zygote: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
I/zygote: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2731)
I/zygote: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2856)
I/zygote: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
I/zygote: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1589)
I/zygote: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
I/zygote: at void android.os.Looper.loop() (Looper.java:164)
I/zygote: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6494)
I/zygote: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/zygote: at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:440)
I/zygote: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:807)
```