【问题标题】:Android 5.0 IllegalArgumentException: Service Intent must be explicit: on com.google.android.location.internal.GoogleLocationManagerService.STARTAndroid 5.0 IllegalArgumentException:服务意图必须明确:在 com.google.android.location.internal.GoogleLocationManagerService.START
【发布时间】:2014-12-04 05:32:27
【问题描述】:

我正在尝试检索在我的活动中调用 LocationClient 类的方法 connect 的设备的位置,但是当调用时系统崩溃以下例外:

**FATAL EXCEPTION: main
Process: com.unipagossales, PID: 3833
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.unipagossales/com.unipagossales.app.merchants.MerchantFragmentActivity}: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.location.internal.GoogleLocationManagerService.START }
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
    at android.app.ActivityThread.access$800(ActivityThread.java:144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5221)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.location.internal.GoogleLocationManagerService.START }
    at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1674)
    at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1773)
    at android.app.ContextImpl.bindService(ContextImpl.java:1751)
    at android.content.ContextWrapper.bindService(ContextWrapper.java:538)
    at com.google.android.gms.internal.v.a(Unknown Source)
    at com.google.android.gms.internal.u.connect(Unknown Source)
    at com.google.android.gms.location.LocationClient.connect(Unknown Source)
    at com.unipagossales.app.merchants.MerchantFragmentActivity.onStart(MerchantFragmentActivity.java:122)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
    at android.app.Activity.performStart(Activity.java:5949)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
    ... 10 more
**

这是我创建 LocationClient 的方式:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.merchant_activity);

    ...

    // Create a new global location parameters object
    locationRequest = LocationRequest.create();
    locationRequest.setInterval(Constants.UPDATE_INTERVAL_MILLISECONDS);
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    locationRequest.setFastestInterval(Constants.FAST_INTERVAL_CEILING_MILLISECONDS);

    // Initialize the location client
    locationClient = new LocationClient(this, new LocationClientConnectionCallbacks(), new LocationClientOnConnectionFailedListener());
}

@Override
protected void onStart() {
    super.onStart();
    ...
    locationClient.connect();
    ...
}

【问题讨论】:

    标签: java android android-intent google-api android-5.0-lollipop


    【解决方案1】:

    将目标 SDK 版本更改为“19”对我有帮助。

    【讨论】:

    • 即使我们使用旧的google play库,如果目标SDK版本为21,应用程序也会崩溃。
    • Sudheesh 你搞清楚了还是还有问题?
    【解决方案2】:

    此问题与 Android VM 在运行时无法在 Google Play 服务中找到动作 act=com.google.android.location.internal.GoogleLocationManagerService.START 的定义有关。

    您需要在下一篇博客之后设置您的 Google Play 服务:

    http://mflerackers.wordpress.com/2014/09/09/noclassdeffounderror-for-googleplayservicesutil/

    然后你需要增加 eclipse.ini 中的 VM 值,按照这个:

    Unable to execute dex: GC overhead limit exceeded in Eclipse

    这应该可以同时修复您的异常。

    【讨论】:

    • 太棒了,这是一个节省!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-22
    • 1970-01-01
    相关资源
    最近更新 更多