當用戶打開一個調用位置管理器的getLastKnownLocation
方法的Activity時,我們已經獲取了某些設備上的崩潰報告。我們要求所有所需的權限在我們的應用程序清單:調用getLastKnownLocation時的SecurityException
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
這裏是堆棧跟蹤:
java.lang.RuntimeException: Unable to resume activity {com.projectname/com.projectname.ui.AtmFinderActivity}: java.lang.SecurityException: invalid package name: com.google.android.gms
at android.app.ActivityThread.performResumeActivity(ActivityThread.java)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$600(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.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
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)
at android.os.Parcel.readException(Parcel.java)
at android.location.ILocationManager$Stub$Proxy.getLastLocation(ILocationManager.java)
at android.location.LocationManager.getLastKnownLocation(LocationManager.java)
at android.privacy.surrogate.PrivacyLocationManager.getLastKnownLocation(PrivacyLocationManager.java)
at com.projectname.util.LocationUtils.getLastKnownLocation(SourceFile:48)
at com.projectname.ui.AtmFinderFragment.initMapIfNeeded(SourceFile:401)
at com.projectname.ui.AtmFinderFragment.onGooglePlayServicesAvailable(SourceFile:187)
at com.projectname.maps.GoogleMapServicesUtil.getGooglePlayServicesStatus(SourceFile:40)
at com.projectname.ui.AtmFinderFragment.onResume(SourceFile:149)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:917)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1080)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1062)
at android.support.v4.app.FragmentManagerImpl.dispatchResume(SourceFile:1820)
at android.support.v4.app.FragmentActivity.onPostResume(SourceFile:412)
at com.actionbarsherlock.app.SherlockFragmentActivity.onPostResume(SourceFile:69)
at android.app.Activity.performResume(Activity.java)
... 13 more
這裏是LocationUtils相關的方法:
public static Location getLastKnownLocation(Context context) {
if (context != null) {
LocationManager lm = (LocationManager) context.getSystemService(
Context.LOCATION_SERVICE);
// Get our last known location
Location location = lm.getLastKnownLocation(
LocationManager.NETWORK_PROVIDER);
if (location == null) {
location = lm.getLastKnownLocation(
LocationManager.GPS_PROVIDER);
}
return location;
}
return null;
}
我們」我們無法在現有的任何設備上重現此問題。有沒有人遇到過這個問題?
這只是猜測,但這味道像一個自定義ROM有一些與我的Google Play服務的問題。我會深入探討您遇到的問題,它們是什麼,Android運行的是什麼,它們是否有某種定製ROM或其他自定義功能會干擾Google Play? – 2013-04-23 18:51:44
@CharlieCollins同意。我們在這個問題上看到的大多數設備都是Galaxy Nexus運行的Android 4.2.2。我還沒有關於他們正在運行的具體構建的任何信息。 – twaddington 2013-04-23 22:06:41
我們也看到這個問題,它看起來像是由於定製ROM。 – 2013-05-14 18:16:46