Mam bardzo dziwny problem. Rozwinąłem swoją aplikację przy użyciu mojego HTC One V z 4.0.3 OS. Teraz aplikacja działa znakomicie na moich i kilku innych losowych urządzeniach 2.2 i 2.3 i 4+, ale na niektórych urządzeniach mimo, że mają GooglePlayStore na nich, aplikacja uruchamia się i ładuje, ale nie pokazuje mapy na innych pomimo posiadania przez nich GPStore aplikacji awarie informujące, że usługa GPStore/Usługa nie jest dostępna.AVD Nie można przetestować żadnej aplikacji za pomocą AVD
Próbowałem przetestować aplikację na AVD Devies, ale żadna z nich nie ma zainstalowanego GooglePlayStore. Próbowałem podejść do nich GPStore, ale bez powodzenia.
My Droid SDK jest w pełni zaktualizowany:
skompilować mojej aplikacji z
W moim głównym aktywności sprawdzić, czy Google Play życzenie/Store jest obecna w celu ustalenia, czy można stosować GoogleMaps :
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 & 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);
}
}
metoda, która sprawdza stan usługi Google Play znajduje się w moim Services.java poniżej:
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);
}
}
A moja mapa jest po prostu obsługiwana w mojej klasie MapAgent, nic nie imponuje po prostu za obsługę znaczników.
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<Atm>();
markers = new HashMap<Marker, Atm>();
// Reference the resources and context
this.resources = context.getResources();
this.context = context;
// Register camera & info window listener with the map
map.setOnCameraChangeListener(this);
//map.setOnInfoWindowClickListener(new ShowDetails(context, resources));
map.setOnMarkerClickListener(new ShowDetails(context));
}
jestem ze wszystkich pomysłów nie mogę Google Play Usługa działa na AVD 2.2+ Próbowałem AVD 4.4 API Google Play chodzi GPService ale ti przyzwyczajenie wyświetlić mapę. Tak więc, aby bezpośrednio wskazać moje pytania dodatkowe:
1) Jeśli wszystkie AVD od 2.2 do 4.4 są wszystkie bez pracy GooglePlay Services, to jak możemy przetestować aplikację dla wielu telefonów i wersji systemu operacyjnego bez konieczności posiadania wielu telefonów.
2) Czy istnieje pewny lub bardziej właściwy sposób wyświetlania GoogleMap na starszych urządzeniach Mówię o systemie Android 2.2+ Użyłem najbardziej banalnego sposobu wyświetlania mojej mapy Mam element Fragment mapy wsparcia w moim xml układu. Problem polega na tym, że niektóre telefony 2.2 i 2.3, które mają GooglePlayStore na nich, lub nie będą otwierać aplikacji, które otwierają aplikację, nie wyświetlają mapy, ale wyświetlają na dole elementy sterowania powiększeniem mapy i logo Google.
3) Dodałem mój plik układu, ale nie mam już mojego telefonu z Androidem i AVD nie pozwala mi przetestować aplikacji, która wymaga GooglePlayServices jest możliwe, że mój układ wyświetlany poniżej powoduje problem z powodu układu nakładki.
Zasadniczo mam układ ramek w tle Mam GoogleMap, a na górze w górnym rogu mam spinner i przycisk. Kiedy ostatnio testowałem tę aplikację, zadziałało to na moim telefonie HTC One V Android 4.0.3.
<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" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<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="" />
<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" />
</FrameLayout>
najprostszym rozwiązaniem:
Do wszystkich przyjaciół, którzy przychodzą całej tej kwestii nie jest w stanie w pełni przetestować aplikacje poprzez AVD zrobić przełącznik do Genymotion Emulator jest wygaszacz życia. Jest szybszy, mniej wadliwy i obsługuje każdą funkcję, jaką ma prawdziwy telefon i znacznie ułatwia testowanie aplikacji na Androida od 2.2.
Poszedłem do Genny i nigdy nie oglądałem się za siebie.
Należy uważać, aby nie pomylić w Sklepie Google Play z usługi Google Play. Wszyscy naprawdę dzielą się imieniem; Sądzę, że w Twoim pytaniu najczęściej masz na myśli Usługi Google Play. –
Czy otrzymujesz wyjątki od LogCat? Podejrzewam, że 'GooglePlayServicesUtil.isGooglePlayServicesAvailable (context)' rzuca wyjątek ClassNotFoundException, ponieważ żadna klasa o nazwie 'GooglePlayServicesUtil' nie jest dostępna w urządzeniu. W takim przypadku powinieneś wychwycić wyjątek i zwrócić 'false'. – ADTC