找不到/缺少AndroidX可穿戴套件

时间:2019-08-14 09:19:34

标签: kotlin wear-os androidx

我正在尝试使用Kotlin和AndroidX实现独立的Android可穿戴式应用程序。

该应用运行正常,但日志显示启动时崩溃(找不到类)。

我曾尝试定位较早的SDK版本,但似乎没有任何解决办法。

有什么建议吗?

2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at int androidx.core.view.ViewCompat.getImportantForAutofill(android.view.View) (ViewCompat.java:730)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.recyclerview.widget.RecyclerView.initAutofill() (RecyclerView.java:748)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.recyclerview.widget.RecyclerView.<init>(android.content.Context, android.util.AttributeSet, int) (RecyclerView.java:675)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.wear.widget.WearableRecyclerView.<init>(android.content.Context, android.util.AttributeSet, int, int) (WearableRecyclerView.java:77)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.wear.widget.WearableRecyclerView.<init>(android.content.Context, android.util.AttributeSet, int) (WearableRecyclerView.java:72)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.wear.widget.WearableRecyclerView.<init>(android.content.Context, android.util.AttributeSet) (WearableRecyclerView.java:68)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear 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-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear 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-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear 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-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void com.android.internal.policy.PhoneWindow.setContentView(int) (PhoneWindow.java:412)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.Activity.setContentView(int) (Activity.java:2414)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void com.ubanquity.xapp.wear.MainActivity.onCreate(android.os.Bundle) (MainActivity.kt:21)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6682)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2618)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2726)
2019-08-14 12:01:45.959 22258-22258/com.ubanquity.xapp.wear 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-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1477)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.os.Looper.loop() (Looper.java:154)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6119)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/system/framework/com.google.android.wearable.jar", zip file "/data/app/com.ubanquity.xapp.wear-1/base.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.ubanquity.xapp.wear-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.ub
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at int androidx.core.view.ViewCompat.getImportantForAutofill(android.view.View) (ViewCompat.java:730)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.recyclerview.widget.RecyclerView.initAutofill() (RecyclerView.java:748)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.recyclerview.widget.RecyclerView.<init>(android.content.Context, android.util.AttributeSet, int) (RecyclerView.java:675)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.wear.widget.WearableRecyclerView.<init>(android.content.Context, android.util.AttributeSet, int, int) (WearableRecyclerView.java:77)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.wear.widget.WearableRecyclerView.<init>(android.content.Context, android.util.AttributeSet, int) (WearableRecyclerView.java:72)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void androidx.wear.widget.WearableRecyclerView.<init>(android.content.Context, android.util.AttributeSet) (WearableRecyclerView.java:68)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear 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-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear 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-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear 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-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void com.android.internal.policy.PhoneWindow.setContentView(int) (PhoneWindow.java:412)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.Activity.setContentView(int) (Activity.java:2414)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void com.ubanquity.xapp.wear.MainActivity.onCreate(android.os.Bundle) (MainActivity.kt:21)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6682)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2618)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2726)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear 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-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1477)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.os.Looper.loop() (Looper.java:154)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6119)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886)
2019-08-14 12:01:45.960 22258-22258/com.ubanquity.xapp.wear I/art:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776)

我的布局文件是:

<?xml version="1.0" encoding="utf-8"?>
<androidx.wear.widget.BoxInsetLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:deviceIds="wear"
        tools:context=".MainActivity">


    <androidx.wear.widget.WearableRecyclerView
            android:id="@+id/wearableRecyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />

    <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"/>

</androidx.wear.widget.BoxInsetLayout>

这是我的Gradle文件:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.ubanquity.xapp.wear"
        minSdkVersion 25
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.android.gms:play-services-wearable:17.0.0'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.wear:wear:1.0.0'
    implementation 'com.google.android.support:wearable:2.4.0'
    compileOnly 'com.google.android.wearable:wearable:2.4.0'

    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.amitshekhar.android:android-networking:1.0.2'
}

0 个答案:

没有答案