Note that there are some explanatory texts on larger screens.

plurals
  1. POAVD Cannot test any application using AVD
    primarykey
    data
    text
    <p>I have a very strange problem I developed my application using my HTC One V running 4.0.3 OS. Now the application works superb on mine and few other random 2.2 and 2.3 and 4+ devices but on some devices despite them having GooglePlayStore on them the application starts and it loads but does not show the map on other despite them having GPStore on them the application crashes saying GPStore/Service is not present. </p> <p>I tried to test the application on AVD Devies but none of them have GooglePlayStore installed. I tried <a href="https://stackoverflow.com/questions/11154222/google-play-on-android-4-0-emulator">Google Play on Android 4.0 emulator</a> approach to push GPStore on to them but no success. </p> <p>My droid SDK is fully updated:<br> <img src="https://i.stack.imgur.com/5qWaV.jpg" alt="enter image description here"></p> <p>I compile my application with <img src="https://i.stack.imgur.com/fvDHg.jpg" alt="enter image description here"></p> <p>In my main activity I check if Google Play Service/Store is present to determine if GoogleMaps can be used: </p> <pre><code>public class Map extends FragmentActivity implements Observer { private MapAgent agent; private Locator locator; private Spinner spinner; private Button gps; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get a new instance of Locator agent locator = new Locator(); // Register as Observer to Locator agent locator.addObserver(this); // Check if Internet connection is available if(Services.connectivityServiceState(this)) { // We have a working Internet connection // Check if we have a GooglePS in operating mode if(Services.playServiceState(this)) { // Load the map setContentView(R.layout.activity_map); // Fetch dropdown list &amp; gps button reference spinner = (Spinner) findViewById(R.id.bankslist); gps = (Button) findViewById(R.id.gpsbttn); // Register event listener with gps button gps.setOnClickListener(new GpsAction(this)); // Register event listener with spinner spinner.setOnItemSelectedListener(new SpinnerAction()); // Fetch our map agent = new MapAgent(this); // Move map camera to initial position agent.initialPosition(); } else { // GooglePS is not in operating mode Messages.playNotificationMessage(this); } } else { // No Internet connection // Prompt user to turn on WiFi or Mobile Messages.internetConnectionRequestMessage(this); } } </code></pre> <p>The method that checks the state of GooglePlay Service is located in my Services.java bellow: </p> <pre><code>public class Services { /** * OPERATING CODES */ private static final int GPS_ERR_REQUEST = 9000; /** * Test device for GooglePlayServices, required for * GoogleMaps API V2. * * @param Activity * @result boolean */ public static boolean playServiceState(Activity context) { // Fetch GooglePS operating code int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); // Check if GooglePS is operating if(code == ConnectionResult.SUCCESS) { // We have GooglePS in working condition return true; } // We have an error, check if it can be resolved by user /*if(GooglePlayServicesUtil.isUserRecoverableError(code)) { // We can solve this error pull up GooglePS guide dialog Dialog guide = GooglePlayServicesUtil.getErrorDialog(code, context, GPS_ERR_REQUEST); // Show the guide dialog guide.show(); // Dispose of our activity context.finish(); }*/ // We do not have GooglePS in operating mode // solve error and retry return false; } /** * Tests devices Wi-Fi and Mobile network for a * working Internet connection. * * @param Activity * @return boolean */ public static boolean connectivityServiceState(Activity context) { // Fetch a CM instance ConnectivityManager con = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); // Test both carriers for a working Internet connection NetworkInfo wifi = con.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mobi = con.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); // Check for Internet connection if(wifi.isConnected() || mobi.isConnected()) { // We have a working internet connection return true; } // No internet connection return false; } /** * Test NETWORK service to determine if Google Location * services are enabled or not. */ public static boolean networkServiceState(Activity context) { // Fetch a LM instance LocationManager provider = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); // Return true for enabled GLS return provider.isProviderEnabled(LocationManager.NETWORK_PROVIDER); } /** * Tests GPS service to determine if GPS * is enabled or not. * * @param Activity * @result boolean */ public static boolean gpsServiceState(Activity context) { // Fetch a LM instance LocationManager provider = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); // Return true for enabled GPS return provider.isProviderEnabled(LocationManager.GPS_PROVIDER); } /** * Checks if a GPS Radio is present * within the device. * * @param Activity * @return boolean */ public static boolean hasGPS(Activity context) { // Refere to devices package manager for GPS service return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS); } } </code></pre> <p>And my map is simply handled in my MapAgent class nothing impressive just handling markers. </p> <pre><code> public MapAgent(FragmentActivity context) { // Fetch the map support fragment SupportMapFragment fragment = ((SupportMapFragment) context.getSupportFragmentManager().findFragmentById(R.id.map)); // Fetch map and view map = fragment.getMap(); // Set initial zoom zoom = 7; // Check if this is the first run final SharedPreferences prefs = context.getSharedPreferences("slo.bankomati.core", Context.MODE_PRIVATE); if(prefs.getBoolean("firstrun", true)) { // Check if database exists and delete it if(Database.exists(context)) { Database.delete(context); } prefs.edit().putBoolean("firstrun", false); } // Fetch all atms try { db = new Database(context); atms = db.getAtms(); db.close(); } catch (Exception e) { // TODO: Temporary solution } // Create an empty array for filtered results filtered = new ArrayList&lt;Atm&gt;(); markers = new HashMap&lt;Marker, Atm&gt;(); // Reference the resources and context this.resources = context.getResources(); this.context = context; // Register camera &amp; info window listener with the map map.setOnCameraChangeListener(this); //map.setOnInfoWindowClickListener(new ShowDetails(context, resources)); map.setOnMarkerClickListener(new ShowDetails(context)); } </code></pre> <p>I'm out of all ideas I can't get GooglePlay Service running on AVD 2.2+ I tried AVD 4.4 Google Play API it comes GPService but ti wont display the map. So to directly point out my sub questions: </p> <p>1) If all AVD's from 2.2 up to 4.4 are all without working GooglePlay Services then how can we test application for multiple phones and OS versions without having multiple phones. </p> <p>2) Is there a sure way or a more proper way to display GoogleMap on older devices I'm talking Android 2.2+ I used the most trivial way to display my map I have a SupportMap Fragment element in my Layout xml. The problem I'm experiencing is that some 2.2 and 2.3 phones that have GooglePlayStore on them will or wont open the application those that do open the application do not display the map but they do display the map zoom controls and Google logo at the bottom.</p> <p>3) I added my layout file but I do not have my android phone anymore and AVD does not let me test application that require GooglePlayServices is it possible that my layout displayed bellow is causing the problem due to overlay layout.</p> <p>I basically have a frame layout in the background I have GoogleMap and on top of that in top corner I have a spinner and a button. When I last tested this application it worked on my phone HTC One V Android 4.0.3.</p> <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/root_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;fragment android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;Button android:id="@+id/gpsbttn" android:layout_width="28dp" android:layout_height="28dp" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:background="@drawable/gps" android:minHeight="28dip" android:minWidth="28dip" android:text="" /&gt; &lt;Spinner android:id="@+id/bankslist" android:layout_width="match_parent" android:layout_height="36dp" android:layout_marginLeft="48dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" android:entries="@array/banks_list" android:prompt="@string/banks_prompt" /&gt; &lt;/FrameLayout&gt; </code></pre> <p><strong>EASIEST SOLUTION:</strong><br> To all friends who come across this issue of not being able to fully test your applications via AVD make the switch to Genymotion Emulator it is a life saver. It is faster, it is less buggy and it supports every single feature a real phone does and makes testing for Android apps since 2.2 so much easier. </p> <p>I went Genny and never looked back.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload