gpt4 book ai didi

java - AVD 无法使用 AVD 测试任何应用程序

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:57:33 27 4
gpt4 key购买 nike

我在使用运行 4.0.3 操作系统的 HTC One V 开发我的应用程序时遇到了一个非常奇怪的问题。现在,该应用程序在我的和其他一些随机的 2.2、2.3 和 4+ 设备上运行良好,但在某些设备上,尽管它们上面安装了 GooglePlayStore,应用程序启动并加载,但在其他设备上不显示 map ,尽管它们上面安装了 GPSstore 应用程序崩溃说 GPSstore/Service 不存在。

我尝试在 AVD Devies 上测试该应用程序,但它们都没有安装 GooglePlayStore。我试过 Google Play on Android 4.0 emulator将 GPSstore 推给他们的方法,但没有成功。

我的机器人 SDK 已完全更新:
enter image description here

我用 enter image description here

在我的主要 Activity 中,我检查是否存在 Google Play 服务/商店以确定是否可以使用 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);
}
}

检查 GooglePlay 服务状态的方法位于我的 Services.java 中:

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);
}
}

我的 map 只是在我的 MapAgent 类中处理,仅仅处理标记就没什么了不起的。

  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));
}

我没有任何想法我无法让 GooglePlay 服务在 AVD 2.2+ 上运行我尝试了 AVD 4.4 Google Play API 它带有 GPService 但我不会显示 map 。所以直接指出我的子问题:

1) 如果从 2.2 到 4.4 的所有 AVD 都没有使用 GooglePlay 服务,那么我们如何在没有多部手机的情况下测试多部手机和操作系统版本的应用程序。

2) 是否有确定的方式或更合适的方式在旧设备上显示 GoogleMap 我说的是 Android 2.2+ 我使用最简单的方式来显示我的 map 我的布局 xml 中有一个 SupportMap Fragment 元素。我遇到的问题是,某些带有 GooglePlayStore 的 2.2 和 2.3 手机会或不会打开应用程序,那些打开应用程序的手机不会显示 map ,但会在底部显示 map 缩放控件和 Google Logo 。

3) 我添加了我的布局文件,但我没有我的 android 手机了,AVD 不允许我测试需要 GooglePlayServices 的应用程序是否有可能是我下面显示的布局由于覆盖布局而导致问题。

我基本上在背景中有一个框架布局,我有 GoogleMap,最重要的是在顶角我有一个微调器和一个按钮。当我上次测试这个应用程序时,它可以在我的手机 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>

最简单的解决方案:
对于遇到无法通过 AVD 完全测试您的应用程序这个问题的所有 friend ,请切换到 Genymotion 模拟器,它可以挽救生命。它速度更快,错误更少,并且支持真实手机的每一个功能,并使自 2.2 以来的 Android 应用程序测试变得更加容易。

我去了 Genny,再也没有回头。

最佳答案

根据这个问题的答案:Google Maps - "App won't run unless you update Google Play services" ,它引用了这篇 Google+ 帖子:https://plus.google.com/+AndroidDevelopers/posts/Tyz491d96Ci ,模拟器不支持在您的应用程序中使用 map ;该帖子中有许多尖刻的回复。

其中一个回复提到了这个问题:This app won't run unless you update Google Play Services (via Bazaar)其中描述了一些模拟器黑客攻击,如果没有其他方法可以尝试。

关于java - AVD 无法使用 AVD 测试任何应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20226181/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com