Fixed
Status Update
Comments
ed...@gmail.com <ed...@gmail.com> #2
The issue is reproducible with core-ktx 1.2.0 and 1.3.0-rc01.
ki...@google.com <ki...@google.com> #3
The Typeface.weight is not a weight of the underlying font file. It is a display style. On older APIs, the display style is adjusted if the Typeface is created from single font. However, after moving to CustomFallbackBuilder, that adjustment is removed since it can crate Typeface from multiple style font files.
Looks like it is good to set display style by ResourcesCompat.getFont for backward compatibility.
ap...@google.com <ap...@google.com> #4
Hi Nona,
Can you please schedule a release after you merge the fix?
ki...@google.com <ki...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 3d6aa2e9b3243dcc4de1f54bd8d40339bd69cb05
Author: Seigo Nonaka <nona@google.com>
Date: Wed May 27 17:38:05 2020
Adjust the Typeface display style with the style of given font
This behavir is implicitly done by Typeface.Builder and
Typeface.createXXX function but not to be done by
Typeface.CustomFallbackBuilder since it is designed to be working
with multiple font files which has different style.
Looks like the style argument is ignored on older API implementation.
Bug: 156853883
Bug: 152023266
Test: ResourcesCompatTest#testGetFont_adjustDisplayStyle passes on 29
Test: ./gradlew core:core:connectedAndroidTest on API 29, 28, 23
Change-Id: I3a377c339a7aed50973cf11df86ddf0069f4ec25
A core/core/src/androidTest/assets/fonts/thin_italic.ttf
A core/core/src/androidTest/assets/fonts/thin_italic.ttx
M core/core/src/androidTest/java/androidx/core/content/res/ResourcesCompatTest.java
A core/core/src/androidTest/res/font/thin_italic.ttf
M core/core/src/main/java/androidx/core/graphics/TypefaceCompatApi29Impl.java
https://android-review.googlesource.com/1318947
Branch: androidx-master-dev
commit 3d6aa2e9b3243dcc4de1f54bd8d40339bd69cb05
Author: Seigo Nonaka <nona@google.com>
Date: Wed May 27 17:38:05 2020
Adjust the Typeface display style with the style of given font
This behavir is implicitly done by Typeface.Builder and
Typeface.createXXX function but not to be done by
Typeface.CustomFallbackBuilder since it is designed to be working
with multiple font files which has different style.
Looks like the style argument is ignored on older API implementation.
Bug: 156853883
Bug: 152023266
Test: ResourcesCompatTest#testGetFont_adjustDisplayStyle passes on 29
Test: ./gradlew core:core:connectedAndroidTest on API 29, 28, 23
Change-Id: I3a377c339a7aed50973cf11df86ddf0069f4ec25
A core/core/src/androidTest/assets/fonts/thin_italic.ttf
A core/core/src/androidTest/assets/fonts/thin_italic.ttx
M core/core/src/androidTest/java/androidx/core/content/res/ResourcesCompatTest.java
A core/core/src/androidTest/res/font/thin_italic.ttf
M core/core/src/main/java/androidx/core/graphics/TypefaceCompatApi29Impl.java
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)
```