鍍金池/ 問答/Python  Android/ 我androidStudio新下載的,一切都是默認(rèn)配置,為何啟動(dòng)會(huì)報(bào)錯(cuò)?

我androidStudio新下載的,一切都是默認(rèn)配置,為何啟動(dòng)會(huì)報(bào)錯(cuò)?

I/art: 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;
           at void android.support.v4.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
           at void android.support.v7.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)




 Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.qky.qingchi.myapplication-2/base.apk"],nativeLibraryDirectories=[/data/app/com.qky.qingchi.myapplication-2/lib/x86, /system/lib, /vendor/lib]]
           at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
           at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
           at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)


           

build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.qky.qingchi.myapplication"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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'
}

styles.xml:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

Base.Theme.AppCompat.Light.DarkActionBar 是我在前面加了base,如果不加無法在右側(cè)預(yù)覽,也不知道為啥

都是默認(rèn)配置,氣死了,這as這么牛逼的東西咋搞的這么垃圾

網(wǎng)上搜有個(gè)說是 sdk tools 26.1.1和這個(gè)com.android.support:appcompat-v7:28.0.0-rc01 我都是默認(rèn)配置有啥不匹配的,再說咋就不匹配了啊, 也沒說清楚,

https://blog.csdn.net/weixin_37651459/article/details/80956366

希望懂的人能告知一下,謝謝,

項(xiàng)目能正常run起來,就是報(bào)錯(cuò),但不影響使用

回答
編輯回答
舊城人

找到了問題原因

build.gradle里面用的api版本 是 28之前選擇虛擬機(jī)選擇的api等級(jí)是 27 ,然后項(xiàng)目里用了28的api,所以報(bào)錯(cuò),虛擬機(jī)改用28的api就沒錯(cuò)了

clipboard.png

2018年8月27日 09:35