在我的应用程序中,当我选择按钮时,它会让我关注 mapView 类,它显示了用户的当前位置。
但是,它抛出
java.lang.RuntimeException: Unable to instantiate activity. ComponentInfo error
我已经在 AndroidManifest 文件中添加了 java 类文件。
我的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">
<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="my api key"/>
</LinearLayout>
我的java类如下
package c.c.c;
import com.google.android.maps.MapActivity;
import android.app.Activity;
import android.os.Bundle;
public class MygoogleActivity extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
我的android清单文件如下
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="c.c.c" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MygoogleActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>