12

我在我发布的应用程序中使用 Android V2 Google 地图库(Google Play 服务)。我一直在 Google Play 中看到零星的异常,这似乎表明支持地图片段偶尔会尝试检查网络状态。但是,库文档没有提到需要此权限。我没有直接在我的应用程序中检查网络状态,所以我没有声明这个权限。因此,SecurityException在扩展支持图片段时有时会抛出 a:

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

我已经在我的清单中声明了相关许可,并将查看是否可以解决问题。但是,令人担忧的是,这只会发生在某些设备上,而不会发生在其他设备上。例如,这在我们的内部测试设备和许多其他设备上运行良好。有人对这个神秘的问题有任何见解吗?它可能是由proguard错误引起的吗?

编辑 1:使用 Google Play 服务库的 2.0.10 (541717-10) 版本时发生此错误。

4

2 回答 2

1

在最新版本的 Google Play 服务库中,文档已更新,表明需要此权限。

发行说明指出了为什么需要此权限:

改进了从获得网络连接中的恢复。此修复需要 ACCESS_NETWORK_STATE 权限。

于 2013-02-26T21:27:41.700 回答
0

是的。任何使用该getActiveNetworkInfo()方法都需要网络状态访问权限。

清单中的以下行应该可以解决问题:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
于 2013-02-07T08:05:51.573 回答