Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.SecurityException: invalid package name: com.google.android.gms

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.

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

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

where

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

and locListener is 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).

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?

Thanks.

like image 923
marko.petrovic Avatar asked Dec 09 '13 15:12

marko.petrovic


People also ask

How to use package names that are already defined in Java?

A simple example is to use a package name that is already defined in Java. For example, let’s create a simple hierarchy, where the parent directory is called java and the sub-directory is called util. Then, we create a sample Java class inside the java/util/ directory, which only prints a message:

What is a securityexception in Java?

This exception is thrown by the security manager, in order to indicate a security violation. The SecurityException class extends the RuntimeException class and thus, belongs to those exceptions that can be thrown during the operation of the Java Virtual Machine (JVM).

Can I change the package name of my Java application?

In the aforementioned case, it is sufficient to change the package name of your application, in order to be executed by the Java Virtual Machine (JVM). In general, you must avoid using package names that are reserved by Java.

Why do I keep getting securityexception when running an applet?

Finally, running an applet from an external source may also result in a SecurityException be thrown. The most frequent reason is that Java applications are blocked by the underlying security settings. For more information on how to change these settings and how to update your Exception Site list, please refer to the instructions here.


1 Answers

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" />
like image 92
nitesh goel Avatar answered Sep 29 '22 15:09

nitesh goel