Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the V2 Maps Library require the ACCESS_NETWORK_STATE permission?

I'm using the Android V2 Google Maps Library (Google Play Services) in my published app. I've been seeing sporadic exceptions show up in Google Play that seem to suggest the support map fragment occasionally tries to check the network state. However, the library documentation does not mention that this permission is required. I don't check the network state directly in my application, so I did not declare this permission. As a result a SecurityException is sometimes thrown when inflating the support map fragment:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.foo/com.foo.ui.TransactionDetailActivity}: android.view.InflateException: Binary XML file line #327: Error inflating class fragment
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    at android.app.ActivityThread.access$600(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5039)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #327: Error inflating class fragment
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:459)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
    at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(SourceFile:119)
    at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SourceFile:262)
    at com.foo.ui.TransactionDetailActivity.onCreate(SourceFile:129)
    at android.app.Activity.performCreate(Activity.java:5104)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
    ... 11 more
Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10106 nor current process has android.permission.ACCESS_NETWORK_STATE.
    at android.os.Parcel.readException(Parcel.java:1425)
    at android.os.Parcel.readException(Parcel.java:1379)
    at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:623)
    at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:425)
    at maps.bm.e.e(Unknown Source)
    at maps.bm.e.a(Unknown Source)
    at maps.z.ag.a(Unknown Source)
    at maps.z.ag.a(Unknown Source)
    at maps.z.ag.a(Unknown Source)
    at maps.z.bw.a(Unknown Source)
    at maps.z.r.onCreateView(Unknown Source)
    at com.google.android.gms.maps.internal.IMapFragmentDelegate$Stub.onTransact(IMapFragmentDelegate.java:107)
    at android.os.Binder.transact(Binder.java:310)
    at com.google.android.gms.maps.a.l.a(Unknown Source)
    at com.google.android.gms.maps.m.a(Unknown Source)
    at com.google.android.gms.internal.ap.a(Unknown Source)
    at com.google.android.gms.internal.al.a(Unknown Source)
    at com.google.android.gms.internal.al.a(Unknown Source)
    at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
    at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:846)
    at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1061)
    at android.support.v4.app.FragmentManagerImpl.addFragment(SourceFile:1160)
    at android.support.v4.app.FragmentActivity.onCreateView(SourceFile:272)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
    ... 28 more

I have declared the relevant permission in my manifest and will see if that fixes the problem. However, it's concerning that this would only happen on some devices and not others. For example, this has worked fine on our internal test devices and many others. Does anyone have any insight into this mysterious issue? Could it be caused by a proguard error?

Edit 1: This error occurred while using version 2.0.10 (541717-10) of the Google Play Services library.

like image 779
twaddington Avatar asked Jan 28 '13 17:01

twaddington


1 Answers

With the latest release of the Google Play Services library the documentation has been updated to indicate this permission is required.

The release notes indicate why this permission is required:

Improved recovery from gaining network connectivity. This fix requires the ACCESS_NETWORK_STATE permission.

like image 98
twaddington Avatar answered Nov 13 '22 13:11

twaddington