android.content.res.Resources.getConfiguration()' on a null object reference

落花浮王杯 提交于 2019-12-13 07:39:55

问题


I have a Service that acts like an overlay with a chathead (like facebook messenger) when the user tap on this chatHead I pop a MapView (v2)

It works for the majority of my users, but in the bug report all the Xiaomi Xiaomi Redmi Note 3 users have the same crash

java.lang.RuntimeException: Unable to create service com.package.MyService: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Configuration android.content.res.Resources.getConfiguration()' on a null object reference at android.app.ActivityThread.handleCreateService(ActivityThread.java) at android.app.ActivityThread.access$1800(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java) at android.os.Handler.dispatchMessage(Handler.java) at android.os.Looper.loop(Looper.java) at android.app.ActivityThread.main(ActivityThread.java) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Configuration android.content.res.Resources.getConfiguration()' on a null object reference at android.view.SurfaceView.init(SurfaceView.java) at android.view.SurfaceView.(SurfaceView.java) at maps.V.x.(Unknown Source) at maps.V.v.(Unknown Source) at maps.D.v.(Unknown Source) at maps.D.v.a(Unknown Source) at maps.ad.ae.a(Unknown Source) at maps.ad.u.a(Unknown Source) at maps.ad.R.a(Unknown Source) at wc.onTransact(:com.google.android.gms.DynamiteModulesB:66) at android.os.Binder.transact(Binder.java) at com.google.android.gms.maps.a.e$a$a.a(Unknown Source) at com.google.android.gms.maps.MapView$a.a(Unknown Source) at com.google.android.gms.dynamic.e.a(Unknown Source) at com.google.android.gms.dynamic.c.a(Unknown Source) at com.google.android.gms.maps.MapView$b.g(Unknown Source) at com.google.android.gms.maps.MapView$b.a(Unknown Source) at com.google.android.gms.dynamic.b.a(Unknown Source) at com.google.android.gms.dynamic.b.a(Unknown Source) at com.google.android.gms.maps.MapView.a(Unknown Source)

The code that seems to fail is here

    this.setTheme(R.style.AppTheme);
    this.myView = LayoutInflater.from(this).inflate(R.layout.my_map, null);
    this.mapView = (MapView) myView.findViewById(R.id.map);
    this.mapView.onCreate(null);
    this.mapView.getMapAsync(this);

The line that throws this error is

this.mapView.getMapAsync(this);

Anyone have a solution for this?


回答1:


Try turning Hardware acceleration on in manifest

android:hardwareAccelerated="true"

it worked for me source: https://code.google.com/p/gmaps-api-issues/issues/detail?id=9071



来源:https://stackoverflow.com/questions/39278242/android-content-res-resources-getconfiguration-on-a-null-object-reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!