NullPointerException 由于尝试在空对象引用上调用虚拟方法“android.os.IBinder android.view.SurfaceControl.getHandle()”

vt6*_*00c 10 android proguard android-proguard google-fabric android-9.0-pie

最近我将我的应用程序迁移到 targetSdkVersion = 28。将更新的应用程序发布到 Google Play 后,我开始在 Fabric.io 中收到非常奇怪的崩溃报告: 崩溃报告

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'android.os.IBinder android.view.SurfaceControl.getHandle()' on a null object reference
android.os.Parcel.createException (Parcel.java:1956)
android.os.Looper.loop (Looper.java:193)
android.app.ActivityThread.main (ActivityThread.java:6718)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Run Code Online (Sandbox Code Playgroud)

当用户从 Play Store 应用程序打开应用程序时,此崩溃仅发生在带有 android Pie 的 Google 设备(Pixel 系列)上,当从主屏幕打开时,一切正常。并且在崩溃报告中没有任何对我的代码的跟踪。

当我禁用 proguard 时,一切都按预期工作

小智 -3

我自己在这个问题上被困了好几个星期,直到我发现这个

buildTypes {
        debug {
            debuggable true
            buildConfigField 'String', "GOOGLE_KEY", GOOGLE_API
            buildConfigField "boolean", "IS_DEBUG", "true"
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            minifyEnabled false
            shrinkResources false
        }
        release {
            debuggable false //This needs to be "true"
            buildConfigField "boolean", "IS_DEBUG", DEBUGABLE
            buildConfigField 'String', "GOOGLE_KEY", GOOGLE_API
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-optimize.pro'
            minifyEnabled false
            proguardFile PROGUARD_FILE
            shrinkResources false
        }
    }
Run Code Online (Sandbox Code Playgroud)

只需将debuggablein更改releasetrue.

  • 在 **release** 构建类型中将 **debuggable** **false** 更改为 **true** 不是我们任何人想要做的。 (3认同)