2013-03-17 49 views
0

我試圖運行一個使用Google Api的庫的android應用程序,並且在輸入地址到輸入字段時輸入地址時調試失敗。Android模擬器調試谷歌地圖Eclipse應用程序

以下是錯誤:http://s1278.beta.photobucket.com/user/cetmrw791346/media/wdyl_zps08bbe17f.png.html?sort=3&o=0

以下是相關文件:

AWhereDoYouLive.java

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> 
+0

創建一個AVD使用谷歌API,然後運行使用它。 – SKK 2013-03-17 06:41:18

回答

0

有一個變通,使谷歌的地圖API V2在您的模擬器上工作,請閱讀下面的博客文章,我寫的更多信息,第二部分:

Google Map API V2 in Emulator

相關問題