java.lang.SecurityException:无效的包名:com.google.android.gms

2022-01-22 00:00:00 gps android java locationmanager

在三星 Galaxy S2 (GT-i9100),Android 版本 4.3 上测试应用程序时,我得到了这个奇怪的堆栈跟踪.如果有帮助,Bugsense 还会报告 "log data" = {​​u'ms_from_start': u'19915', u'rooted': u'true'} ,所以我不太确定该设备是否已植根(客户端正在测试应用程序,而不是我).当我输入这个时,客户确认我的设备有自定义 ROM,如果重要的话.

I've got this weird stack trace while testing the app on Samsung Galaxy S2 (GT-i9100), Android version 4.3. If it helps, Bugsense reports also "log data" = {u'ms_from_start': u'19915', u'rooted': u'true'} , so I'm not quite sure if this device is rooted or not (client is testing the app, not me). While I'm typing this, client confirmed me that the device is having custom ROM, if it matters.

总之,这是一个完整的堆栈跟踪:

Anyhow, this is a complete stack trace:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackagename/com.mypackagename.activities.ARActivity}: 

java.lang.SecurityException: invalid package name: com.google.android.gms
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
    at android.app.ActivityThread.access$600(ActivityThread.java:156)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5303)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
    at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.SecurityException: invalid package name: com.google.android.gms
    at android.os.Parcel.readException(Parcel.java:1431)
    at android.os.Parcel.readException(Parcel.java:1385)
    at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:540)
    at android.location.LocationManager.requestLocationUpdates(LocationManager.java:836)
    at android.location.LocationManager.requestLocationUpdates(LocationManager.java:430)
    at android.privacy.surrogate.PrivacyLocationManager.requestLocationUpdates(PrivacyLocationManager.java:290)
    at com.mypackagename.activities.ARActivity.onCreate(ARActivity.java:371)
    at android.app.Activity.performCreate(Activity.java:5259)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1098)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)

现在,ARActivity.java:371 正在调用

Now, ARActivity.java:371 is just calling

locationManager.requestLocationUpdates(GPS, gpsRefreshPeriod, 0, locListener);

在哪里

private String GPS = "gps";
private int gpsRefreshPeriod = 500;

而 locListener 是 locationListener.

and locListener is locationListener.

现在,我不知道这里可能出了什么问题,而且我无法在我的测试设备(Samsung Galaxy Tab2、Motorola Atrix 4G、Samsung Note2、Galaxy Nexus)上重现此错误.

Now, I have no idea what could go wrong here, and I can't reproduce this error on my testing devices (Samsung Galaxy Tab2, Motorola Atrix 4G, Samsung Note2, Galaxy Nexus).

我想可能会以某种方式检查 com.google.android.gms,并且可能存在 Intent(或其他东西)在丢失该包的情况下,用户会更新设备的组件.但我完全没有确定我是否会带着这种想法走向正确的方向.

I guess there could be a check for com.google.android.gms somehow, and maybe there could be Intent (or something) that in case of missing that package, user updates device's component.. But I'm totally not sure if I'm going into the right direction with this thinking.

对这次崩溃有什么想法或经验吗?

Any ideas or experience with this crash?

谢谢.

推荐答案

在我看来,这台设备根本没有安装 GoogleApps 应用程序.自定义 ROM 实际上可能是一个提示.例如,该设备的所有者可能已经安装了 Cyanogenmod,但他忘记了(或故意没有安装)Google Apps,提供 单独.

It seems to me that this device simply does not have GoogleApps application installed. The custom ROM actually may be a hint for this. For instance, an owner of this device might have installed Cyanogenmod but he has forgotten (or deliberately has not installed) Google Apps, which are supplied separately.

相关文章