2011-11-17 4 views
1

다음과 같은 문제가 발생합니다 (LogCat에 표시됨). 나는 안드로이드 애플리케이션 개발에 익숙하기 때문에 any1이 나를 도와 줄 수 있기를 바랍니다.맞춤형 Android 애플리케이션에서 Google지도 사용하기

11-17 16:50:38.087: E/AndroidRuntime(372): FATAL EXCEPTION: main 
    11-17 16:50:38.087: E/AndroidRuntime(372): java.lang.IllegalStateException: Could not  execute method of the activity 
    11-17 16:50:38.087: E/AndroidRuntime(372): at android.view.View$1.onClick(View.java:2072) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at android.view.View.performClick(View.java:2408) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at android.view.View$PerformClick.run(View.java:8816) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at android.os.Handler.handleCallback(Handler.java:587) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at android.os.Handler.dispatchMessagev(Handler.java:92) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at android.os.Looper.loop(Looper.java:123) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at android.app.ActivityThread.main(ActivityThread.java:4627) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.reflect.Method.invokeNative(Native Method) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.reflect.Method.invoke(Method.java:521) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at dalvik.system.NativeStart.main(Native Method) 
    11-17 16:50:38.087: E/AndroidRuntime(372): Caused by: java.lang.reflect.InvocationTargetException 
    11-17 16:50:38.087: E/AndroidRuntime(372): at com.mspl.activities.AlertListActivity.doShow(AlertListActivity.java:144) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.reflect.Method.invokeNative(Native Method) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.reflect.Method.invoke(Method.java:521)enter code here 
    11-17 16:50:38.087: E/AndroidRuntime(372): at android.view.View$1.onClick(View.java:2067) 
    11-17 16:50:38.087: E/AndroidRuntime(372): ... 11 more 
    11-17 16:50:38.087: E/AndroidRuntime(372): Caused by: java.lang.NoClassDefFoundError: com.mspl.activities.AlertLocationActivity 
    11-17 16:50:38.087: E/AndroidRuntime(372): ... 15 more 
    11-17 16:50:38.087: E/AndroidRuntime(372): Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation 
    11-17 16:50:38.087: E/AndroidRuntime(372): at dalvik.system.DexFile.defineClass(Native Method) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:209) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:203) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.ClassLoader.loadClass(ClassLoader.java:573) 
    11-17 16:50:38.087: E/AndroidRuntime(372): at java.lang.ClassLoader.loadClass(ClassLoader.java:532) 
    11-17 16:50:38.087: E/AndroidRuntime(372): ... 15 more  

이 내 AlertListActivity.java 파일입니다 : - :

package com.mspl.activities; 

    import java.util.List; 

    import android.graphics.drawable.Drawable; 
    import android.os.Bundle; 

    import com.google.android.maps.GeoPoint; 
    import com.google.android.maps.MapActivity; 
    import com.google.android.maps.MapView; 
    import com.google.android.maps.Overlay; 
    import com.google.android.maps.OverlayItem; 

    public class AlertLocationActivity extends MapActivity 
{ 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.mapview); 

     MapView mapView = (MapView) findViewById(R.id.mapView); 
     mapView.setBuiltInZoomControls(true); 

     List<Overlay> mapOverlays = mapView.getOverlays(); 
     Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker); 
     HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable); 

     GeoPoint point = new GeoPoint(19240000,-99120000); 
     OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!"); 

     itemizedoverlay.addOverlay(overlayitem); 
     mapOverlays.add(itemizedoverlay); 
    } 

    @Override 
    protected boolean isRouteDisplayed() { 
     return false; 
    } 

} 

의 AndroidManifest.xml 파일 : - -

package com.mspl.activities; 
    enter code here 
    import java.util.ArrayList; 
    import java.util.Date; 
    import java.util.HashMap; 

    import android.app.ListActivity; 
    import android.content.Intent; 
    import android.os.Bundle; 
    import android.view.View; 
    import android.widget.LinearLayout; 
    import android.widget.ListView; 
    import android.widget.SimpleAdapter; 
    import android.widget.TextView; 

    public class AlertListActivity extends ListActivity { 
    static final ArrayList<HashMap<String, String>> list2 = new ArrayList<HashMap<String, String>>(); 
    Date date; 
    HashMap<String, String> map = new HashMap<String, String>(); 
    static int flag = 0; 
    SimpleAdapter a; 
    int selectedIndex = 0; 

    // AlertAdapter sa; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.alert); 
     //addContentView(R.layout.crowview,new ViewGroup.LayoutParams(this)); 
     SimpleAdapter adapter = new SimpleAdapter(this, list2, R.layout.crowview, new String[] { "alert_type", "date", "identity"}, new int[] { R.id.alarmType, R.id.date, R.id.identity}); 
     populateList(); 
     a = adapter; 
     setListAdapter(adapter); 
    } 


    public void populateList() //Statically filling the ArrayList with HashMap values 
    { 

     if (flag == 0) // For entry to be entered only once 
     { 
      flag = 1; 
      map.put("alert_type", "Alert_1"); 
      date = new Date(121, 11, 9, 17, 5, 00); 
      map.put("date", date.toString()); 
      map.put("identity", "9001"); 
      list2.add(map); 

      map = new HashMap<String, String>(); 
      map.put("alert_type", "Alert_2"); 
      date = new Date(111, 11, 9, 17, 5, 05); 
      map.put("date", date.toString()); 
      map.put("identity", "9002"); 
      list2.add(map); 

      map = new HashMap<String, String>(); 
      map.put("alert_type", "Alert_3"); 
      date = new Date(111, 11, 9, 17, 5, 10); 
      map.put("date", date.toString()); 
      map.put("identity", "9003"); 
      list2.add(map); 

      map = new HashMap<String, String>(); 
      map.put("alert_type", "Alert_4"); 
      date = new Date(111, 11, 9, 17, 5, 15); 
      map.put("date", date.toString()); 
      map.put("identity", "9004"); 
      list2.add(map); 

      map = new HashMap<String, String>(); 
      map.put("alert_type", "Alert_5"); 
      date = new Date(111, 11, 9, 17, 5, 20); 
      map.put("date", date.toString()); 
      map.put("identity", "9005"); 
      list2.add(map); 
     } 

    } 

    public void onAck(View view) //Performs Delete operation on Alert List 
    { 
     ListView lv1 = getListView(); 
//  long i2 = lv1.getSelectedItemPosition(); 
     //lv1.setSelection(i2); 
//  int i3 = view.getId(); 


     //list2.remove(i2); 

     LinearLayout llv = (LinearLayout)view.getParent().getParent(); 
     LinearLayout llv2 = (LinearLayout)llv.getChildAt(0); 
     TextView child = (TextView)llv2.getChildAt(0); 


     //Toast.makeText(getApplicationContext(),((TextView)child).getText(), Toast.LENGTH_SHORT).show(); 
     for(int i=0 ; i<list2.size() ; i++) 
     { 
      HashMap<String, String> hm = list2.get(i); 
      String str = hm.get("identity"); 
      if(str.equals(child.getText())) 
      { 
       list2.remove(i); 
       break; 
      } 
     } 

     lv1.refreshDrawableState(); 
     a.notifyDataSetChanged(); 
     a.notifyDataSetInvalidated(); 

    } 



    public void doShow(View view) 
    { 
     try{ 
     Intent intent = new Intent(AlertListActivity.this, AlertLocationActivity.class); 
     startActivity(intent); 
     } 
     catch(Exception e) 
     { 
      e.printStackTrace(); 
     } 
    } 


    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) //Listener for ListView Item click 
    { 
     super.onListItemClick(l, v, position, id); 
     selectedIndex = position; 
     Object o = this.getListAdapter().getItem(position); 

     String str = o.toString(); 
     // Toast.makeText(this, "You have chosen: " + " " + str, 
     // Toast.LENGTH_LONG).show(); 
     Intent i = new Intent(this, AlertDetailsActivity.class); 
     i.putExtra("str", str); 
     startActivity(i); 

    } 

} 

이 내 AlertLocationActivity.java 파일입니다

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.mspl.activities" android:versionCode="1" 
    android:versionName="1.0"> 

    <uses-sdk android:minSdkVersion="8" /> 

    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".MainActivity" android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     <activity android:name=".ShowVehicleListActivity" 
      android:label="@string/vehicle.list.screen" /> 

     <activity android:name=".AlertListActivity" 
      android:label="@string/alert.list.screen" /> 

     <activity android:name=".AlertDetailsActivity" 
      android:label="@string/alert2.list.screen" /> 


     <uses-library android:name="com.google.android.maps" /> 

     <activity android:name=".AlertLocationActivity" 
      android:label="@string/alert.loc.screen" /> 

    </application> 
     <uses-permission android:name="android.permission.INTERNET" /> 
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
     <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> 
    </manifest> 

그리고 이것은 m입니다. y를 mapview.xml 파일 : -

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
    <com.google.android.maps.MapView 
     android:id="@+id/mapView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:enabled="true" 
     android:clickable="true" 
     android:apiKey="0WYMWNJ2XW382cucH2luf4o6bRtkU7W6vROnlrg" 
    /> 
    <LinearLayout android:id="@+id/zoom" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    /> 
    </RelativeLayout> 
+2

심각하게? 우리는 초능력이 아니므로 소스 코드를 게시하십시오 ... –

+0

http://stackoverflow.com/questions/3621163/cannot-resolve-mapactivity-class-on-android – Selvin

+0

매니페스트 파일에 AlertLocationActivity를 선언 했습니까? –

답변

3

확인합니다.

두 개의 Google API 라이브러리가 Google API 폴더를 표시하지 않아도 참조되는 중입니다. 나는 내가 그것을 사용하고있는 응용 프로그램을 만든 후에 내가 Google지도 플러그인을 설치했기 때문에 이것이 일어 났음이 틀림 없다.

해결책은 "빌드 경로 구성"에서 "maps.jar"에 대한 참조를 제거한 다음 새 Android 프로젝트를 만들고 Google API 폴더를 현재 프로젝트에 복사하여 붙여 넣기 만하면됩니다.

어쨌든 고맙습니다 ...

1

당신은 Manifest 파일> < 응용 프로그램 내에서 태그를

<uses-library android:name="com.google.android.maps" /> 

을 추가 했습니까?

또한 내가 그것을 해결 한 Cannot resolve MapActivity class on Android