내 코드 내에서 mapview에서 googlemaps를로드하려고합니다.활동에서지도보기를 시작할 수 없습니다.
활동이로드되자 마자 LogCat에 다음과 같은 오류가 생성됩니다.
내 코드에서 명백한 것을 볼 수 없다. 튜토리얼 메신저로 추가 JAR 파일을 가져 오지 않는다. dosent를 사용하면이 간단한 단계에서 필수적이라고 말한다.
02-17 19:47:01.889: E/AndroidRuntime(300): FATAL EXCEPTION: main
02-17 19:47:01.889: E/AndroidRuntime(300): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.mapdb/com.example.mapdb.GoogleMapsActivity}: java.lang.ClassNotFoundException: com.example.mapdb.GoogleMapsActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.example.mapdb-2.apk]
02-17 19:47:01.889: E/AndroidRuntime(300): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
02-17 19:47:01.889: E/AndroidRuntime(300): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-17 19:47:01.889: E/AndroidRuntime(300): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-17 19:47:01.889: E/AndroidRuntime(300): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-17 19:47:01.889: E/AndroidRuntime(300): at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 19:47:01.889: E/AndroidRuntime(300): at android.os.Looper.loop(Looper.java:123)
02-17 19:47:01.889: E/AndroidRuntime(300): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-17 19:47:01.889: E/AndroidRuntime(300): at java.lang.reflect.Method.invokeNative(Native Method)
02-17 19:47:01.889: E/AndroidRuntime(300): at java.lang.reflect.Method.invoke(Method.java:521)
02-17 19:47:01.889: E/AndroidRuntime(300): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-17 19:47:01.889: E/AndroidRuntime(300): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-17 19:47:01.889: E/AndroidRuntime(300): at dalvik.system.NativeStart.main(Native Method)
02-17 19:47:01.889: E/AndroidRuntime(300): Caused by: java.lang.ClassNotFoundException: com.example.mapdb.GoogleMapsActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.example.mapdb-2.apk]
02-17 19:47:01.889: E/AndroidRuntime(300): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-17 19:47:01.889: E/AndroidRuntime(300): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-17 19:47:01.889: E/AndroidRuntime(300): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-17 19:47:01.889: E/AndroidRuntime(300): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
02-17 19:47:01.889: E/AndroidRuntime(300): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
02-17 19:47:01.889: E/AndroidRuntime(300): ... 11 more
매니페스트 :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapdb"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".GoogleMapsActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
주요 활동 클래스 :
package com.example.mapdb;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class MainActivity extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//fetch the map view from the layout
MapView mapView = (MapView) findViewById(R.id.mapview);
//make available zoom controls
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
임 잘못가는 곳 :
오류를 로그 캣에서
희망 일부 볼 수 있습니다 활동 ty_main.xml 레이아웃 : 자바 코드에서
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0xxxxxxxxxxxxxxxxxxxxg"
android:clickable="true" />
</LinearLayout>
2012 년 12 월부터 API 키가 감가 상각되었습니다. Google Maps API v2를 사용하여 새 메소드를 구현해야합니다. [이 공식 문서] (https://developers.google.com/maps/documentation/android/v1/)를 읽어보십시오. – BBonDoo