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

时间:2022-06-26 08:15:07

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). EDIT: While I'm typing this, client confirmed me that the device is having custom ROM, if it matters.

我在三星Galaxy S2 (GT-i9100)和安卓4.3上测试这款应用时,得到了这个奇怪的堆栈跟踪。如果有帮助的话,Bugsense报告还会“日志数据”= {u'ms_from_start': u'19915', u'root ': u'true'},所以我不太确定这个设备是否已被根化(客户端正在测试这个应用程序,而不是我)。编辑:当我输入这个的时候,客户确认我的设备有自定义ROM(如果重要的话)。

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)

Now, ARActivity.java:371 is just calling

现在,ARActivity。java:371只是调用

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

where

在哪里

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

and locListener is locationListener.

locListener locationListener。

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).

现在,我不知道这里会出现什么问题,我无法在我的测试设备上重现这个错误(三星Galaxy Tab2、摩托罗拉Atrix 4G、三星Note2、Galaxy Nexus)。

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.

我想可能会有com。google。android的支票。gms在某种程度上,可能有意图(或某些东西),如果丢失了那个包,用户就会更新设备的组件。但我完全不确定我的想法是否正确。

Any ideas or experience with this crash?

有什么想法或经验吗?

Thanks.

谢谢。

4 个解决方案

#1


1  

try to use

尝试使用

<uses-library android:name="com.google.android.gms" />

under application tag. Example

在应用程序标记。例子

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name" >
    <uses-library android:name="com.google.android.gms" />

#2


1  

Some devices that i use for testing doesn´t have capabilities to support gps and get the location, that was the reason for what i got the exception

一些我所使用的设备进行测试并´t功能支持gps和位置,这是我异常的原因

"invalid package name: com.google.android.gms"

“无效的包名称:com.google.android.gms”

We must add permissions required

我们必须添加所需的权限

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>  

and very important add android:required=false" for GPS.

并且非常重要的添加android:required=false,用于GPS。

  <uses-feature
         android:name="android.hardware.location.gps"
         android:required="false" />

More info: <uses-feature>

更多信息:< uses-feature >

#3


1  

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.

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

#4


0  

These 2 questions are very similar:

这两个问题非常相似:

SecurityException when calling getLastKnownLocation

SecurityException当调用getLastKnownLocation

Add Google Maps to my app

添加谷歌地图到我的应用

Perhaps the issue is with the custom ROM and you need to attach the Play Services Android library project to your project.

也许问题出在自定义ROM上,您需要将Play Services Android library项目附加到您的项目中。

#1


1  

try to use

尝试使用

<uses-library android:name="com.google.android.gms" />

under application tag. Example

在应用程序标记。例子

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name" >
    <uses-library android:name="com.google.android.gms" />

#2


1  

Some devices that i use for testing doesn´t have capabilities to support gps and get the location, that was the reason for what i got the exception

一些我所使用的设备进行测试并´t功能支持gps和位置,这是我异常的原因

"invalid package name: com.google.android.gms"

“无效的包名称:com.google.android.gms”

We must add permissions required

我们必须添加所需的权限

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>  

and very important add android:required=false" for GPS.

并且非常重要的添加android:required=false,用于GPS。

  <uses-feature
         android:name="android.hardware.location.gps"
         android:required="false" />

More info: <uses-feature>

更多信息:< uses-feature >

#3


1  

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.

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

#4


0  

These 2 questions are very similar:

这两个问题非常相似:

SecurityException when calling getLastKnownLocation

SecurityException当调用getLastKnownLocation

Add Google Maps to my app

添加谷歌地图到我的应用

Perhaps the issue is with the custom ROM and you need to attach the Play Services Android library project to your project.

也许问题出在自定义ROM上,您需要将Play Services Android library项目附加到您的项目中。