Showing posts with label Google Play services SDK. Show all posts
Showing posts with label Google Play services SDK. Show all posts

Wednesday, January 2, 2013

!!!updated - Google Play services is not supported on the Android emulator


update@2013-07-26

With Android SDK updated, Google Play services SDK is now supported in Android Emulator with AVD that runs the Google APIs platform based on Android 4.2.2 or higher. Read the updated post.



Please don't test your app using Google Play services API (include Google Maps Android API v2) on Android emulator, because Google Play services is not supported on the Android emulator — to develop using the APIs, you need to provide a development device such as an Android phone or tablet; refer Google Play services SDK document.

Google Play Store is missing

Google Play services is not supported on the Android emulator



Friday, December 28, 2012

Check if correct Google Play Service available for Google Maps Android API v2

According to Google Play Services Document, apps using Google Play Service API should Ensuring Devices Have the Google Play services APK. So we have to check isGooglePlayServicesAvailable() and call getErrorDialog() if not SUCCESS.

Actually in my trial experience to uninstall Google Play Service before running. The app will ask to install Google Play Service automatically, even I haven't check isGooglePlayServicesAvailable(). So I can't clarify if my code work correctly or not!

update@2013-07-16: show() must be called. ~ thanks Morrox comment.
 
 GooglePlayServicesUtil.getErrorDialog(resultCode, this, RQS_GooglePlayServices).show();
 


Check if correct Google Play Service available for Google Maps Android API v2


Modify the java code from the last post "Include open source software license information/Legal Notices in your app using Google Maps Android API v2", to check isGooglePlayServicesAvailable() in onResume().

package com.example.androidmapsv2;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;

import android.app.AlertDialog;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends FragmentActivity {
 
 final int RQS_GooglePlayServices = 1;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
 }
 
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.activity_main, menu);
  return true;
 }

 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
     case R.id.menu_legalnotices:
      String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(
        getApplicationContext());
      AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(MainActivity.this);
      LicenseDialog.setTitle("Legal Notices");
      LicenseDialog.setMessage(LicenseInfo);
      LicenseDialog.show();
         return true;
     }
  return super.onOptionsItemSelected(item);
 }

 @Override
 protected void onResume() {
  // TODO Auto-generated method stub
  super.onResume();

  int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
  
  if (resultCode == ConnectionResult.SUCCESS){
   Toast.makeText(getApplicationContext(), 
     "isGooglePlayServicesAvailable SUCCESS", 
     Toast.LENGTH_LONG).show();
  }else{
   GooglePlayServicesUtil.getErrorDialog(resultCode, this, RQS_GooglePlayServices);
  }
  
 }

}


download filesDownload the files.


The series:
A simple example using Google Maps Android API v2, step by step.

Wednesday, December 19, 2012

Add reference library google-play-services.jar to project using MapFragment and SupportMapFragment

To use MapFragment or SupportMapFragment on your Android App, you have to add reference library google-play-services.jar to your project. Otherwise, ClassNotFoundException will be thrown caused by com.google.android.gms.maps.MapFragment or com.google.android.gms.maps.SupportMapFragment.

To add reference library google-play-services.jar:

- Right click on your project, select Properties.


- Select Android on the left selection, scroll down to the Library at right, and click Add.

- Select google-play-services_lib and click OK.

- Apply and click OK.


The series:
A simple example using Google Maps Android API v2, step by step.







Remark: Somebody report that ClassNotFOundException still happen even added reference library google-play-services.jar! Refer to comments in the post Using SupportMapFragment. So anybody have any other suggestion, please share in comments. Thanks.

Related:
- Tips to add Support Library


Friday, December 14, 2012

Setup Google Play services SDK in Eclipse

The Google Play services SDK is an extension to the Android SDK and is available as a downloadable package from the SDK Manager. The download includes the client library and code samples.

To develop using the Google Play services APIs, you must download the Google Play services SDK. Google Play services is not supported on the Android emulator, a physical device runs Android 2.2 or higher must be used to run and debug apps using Google Play services SDK.

To install Google Play services SDK from Eclipse:

- Window > Android SDK Manager.

- Scroll to the bottom of the package list, select and install Extras > Google Play services.

- Accept and install.

- After installed, import the library project into your workspace. Click File > Import

- Select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.

- click Browse to select <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib, and click Finish.


The series:
A simple example using Google Maps Android API v2, step by step.