Android模拟器调试谷歌地图Eclipse应用程序
我正在尝试使用谷歌Api库运行android应用程序,在调试时在输入字段中输入地址时收到启动失败错误 以下是错误: 及 以下是相关文件: AWhereDoYouLive.javaAndroid模拟器调试谷歌地图Eclipse应用程序,android,android-emulator,google-api,Android,Android Emulator,Google Api,我正在尝试使用谷歌Api库运行android应用程序,在调试时在输入字段中输入地址时收到启动失败错误 以下是错误: 及 以下是相关文件: AWhereDoYouLive.java package com.example.wheredoyoulive; import android.app.Activity; import android.app.AlertDialog; import android.content.Intent; import android.net.Uri; import
package com.example.wheredoyoulive;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class AWhereDoYouLive extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
final AlertDialog.Builder adb = new AlertDialog.Builder(this);
final EditText addressfield = (EditText) findViewById(R.id.address);
final Button button = (Button) findViewById(R.id.launchmap);
button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
try {
// Perform action on click
String address = addressfield.getText().toString();
address = address.replace(' ', '+');
Intent geoIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + address));
startActivity(geoIntent);
} catch (Exception e) {
AlertDialog ad = adb.create();
ad.setMessage("Failed to Launch");
ad.show();
}
}
});
}
}
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please enter your home address."
/>
<EditText
android:id="@+id/address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoText="true"
/>
<Button
android:id="@+id/launchmap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Map"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Unlocking Android, Chapter 1."
/>
</LinearLayout>
AndroidMainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wheredoyoulive"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/icon" >
<activity android:label="@string/app_name"
android:name="com.example.wheredoyoulive.AWhereDoYouLive">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<users-permission android:name="android.permission.INTERNET" />
</manifest>
当仔细检查Google services设置页面时:Google Play services似乎不受任何可用Android模拟器的支持。有一种方法可以让Google Map API V2在模拟器上工作,请阅读我写的以下博文的第二部分以了解更多信息:
使用Google API创建AVD,然后使用它运行。