当前位置: 首页 > 知识库问答 >
问题:

Android 10上的应用程序崩溃(layout/abc_screen_simple第17行中的flateexception)

茹正祥
2023-03-14
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/telegram.free.sticker.MainActivity}: android.view.InflateException: Binary XML file line #17 in com.example.app:layout/abc_screen_simple: Binary XML file line #17 in com.example.app:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3654)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3806)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
     Caused by: android.view.InflateException: Binary XML file line #17 in com.example.app:layout/abc_screen_simple: Binary XML file line #17 in com.example.app:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
     Caused by: android.view.InflateException: Binary XML file line #17 in com.example.app:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference
    at com.asha.nightowllib.inflater.InjectedInflaterBase.getConstructorArgs(InjectedInflaterBase.java:81)
        at com.asha.nightowllib.inflater.LastChance2Inflater.lastChance2CreateView(LastChance2Inflater.java:22)
        at com.asha.nightowllib.inflater.InjectedInflaterV11$PrivateFactoryWrapperImpl.onCreateView(InjectedInflaterV11.java:189)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:659)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:920)
        at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:693)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
        at telegram.free.sticker.MainActivity.onCreate(MainActivity.java:52)
        at android.app.Activity.performCreate(Activity.java:7963)
        at android.app.Activity.performCreate(Activity.java:7952)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3629)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3806)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
2021-01-22 17:16:26.209 24854-24854/com.signalmeme.stickers E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</androidx.drawerlayout.widget.DrawerLayout>

我的建筑。Gradle

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
}

android {
    compileSdkVersion 30
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0-rc01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.navigation:navigation-fragment:2.3.2'
    implementation 'androidx.navigation:navigation-ui:2.3.2'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.squareup.retrofit2:retrofit:2.6.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.6.2'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'com.facebook.android:audience-network-sdk:6.2.0'
    implementation 'com.asha.nightowllib:nightowllib:0.2'
    implementation 'com.facebook.shimmer:shimmer:0.5.0'

    //Firebase
    implementation platform('com.google.firebase:firebase-bom:26.2.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-messaging'
    implementation 'com.google.firebase:firebase-inappmessaging-display'
    implementation 'com.google.firebase:firebase-crashlytics'

}

共有1个答案

卢阳泽
2023-03-14

所以多亏了@commonsware评论,我可以通过删除

implementation 'com.asha.nightowllib:nightowllib:0.2'

这个库是该应用程序在Android 10设备上崩溃的原因。

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference
    at com.asha.nightowllib.inflater.InjectedInflaterBase.getConstructorArgs(InjectedInflaterBase.java:81)
        at com.asha.nightowllib.inflater.LastChance2Inflater.lastChance2CreateView(LastChance2Inflater.java:22)
        at com.asha.nightowllib.inflater.InjectedInflaterV11$PrivateFactoryWrapperImpl.onCreateView(InjectedInflaterV11.java:189)

对于将来可能发生类似崩溃的任何人,请查看堆栈跟踪,查找对您添加的库的任何引用,这可能是罪魁祸首。

 类似资料: