com.google.android.gms.location.LocationClient的实例化挂起

时间:2014-04-11 14:16:02

标签: android google-play-services android-library location-client

我正在使用Android Studio开发Android-library项目,该项目使用google-play-services来使用Geofences API。

要包含Play服务,我使用maven(gradle.build文件中的构建规则),就像官方Android文档显示的那样(http://developer.android.com/google/play-services/setup.html#Setup)。在此Android库中,我在实例化GooglePlayServicesUtil.isGooglePlayServicesAvailable之前验证了Google Play服务是否可用LocationClient方法。

Log.d(TAG, "Registering geofences");
try{
    if(GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) != ConnectionResult.SUCCESS){
        Log.e(TAG, "Google Play Services unavailable");
        return;
    }else
        Log.d(TAG, "Google Play Services are available");
    Log.d(TAG, "creating LocationClient");
    locationClient = new LocationClient(context, this, this);
    Log.d(TAG, "connecting LocationClient");
    locationClient.connect();
} catch (Exception e) {
    e.printStackTrace();
}

这是我从Logcat获得的日志:

04-11 09:45:27.331  23741-23781/foo.bar.myoldapp D/AWRLocationService﹕ Registering geofences
04-11 09:45:27.331  23741-23781/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3086 (common_google_play_services_install_title) in Lcom/google/android/gms/R$string;
04-11 09:45:27.331  23741-23781/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x004b
{... and around 20 similar lines ...}
04-11 09:45:27.341  23741-23781/foo.bar.myoldapp E/GooglePlayServicesUtil﹕ The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
04-11 09:45:27.351  23741-23781/foo.bar.myoldapp D/AWRLocationService﹕ Google Play Services are available
04-11 09:45:27.351  23741-23781/foo.bar.myoldapp D/AWRGeofencesReceiver﹕ creating LocationClient
04-11 09:45:27.351  23741-23781/foo.bar.myoldapp W/dalvikvm﹕ VFY: unable to resolve static field 3100 (location_client_powered_by_google) in Lcom/google/android/gms/R$string;
04-11 09:45:27.351  23741-23781/foo.bar.myoldapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0019
04-11 09:45:30.731  23741-23741/foo.bar.myoldapp D/AWRWifiScanResultBroadcastReceiver﹕ onReceive

正如您所看到的,Google Play服务似乎并不完全包含在我不知道的原因中(因为我按照Google要求的方式包含它们)。但它们似乎存在,因为GooglePlayServicesUtil.isGooglePlayServicesAvailable返回true。然后,我实例化LocationClient并且没有任何反应。不会抛出异常,也不会显示错误日志。我做错了什么?

0 个答案:

没有答案