我已成功完成所有流程以启动google map v2, 但在运行时它通过class not found错误, 如何摆脱这些东西
这是xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
这是我的代码
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class MainActivity extends FragmentActivity {
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_location);
map = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
}
}
logcat的
02-20 11:44:56.103: E/AndroidRuntime(1394): FATAL EXCEPTION: main
02-20 11:44:56.103: E/AndroidRuntime(1394): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
02-20 11:44:56.103: E/AndroidRuntime(1394): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
02-20 11:44:56.103: E/AndroidRuntime(1394): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:271)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-20 11:44:56.103: E/AndroidRuntime(1394): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.app.Activity.setContentView(Activity.java:1647)
02-20 11:44:56.103: E/AndroidRuntime(1394): at com.curioussolutions.autoistdiary.MainActivity.onCreate(MainActivity.java:26)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.os.Handler.dispatchMessage(Handler.java:99)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.os.Looper.loop(Looper.java:123)
02-20 11:44:56.103: E/AndroidRuntime(1394): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-20 11:44:56.103: E/AndroidRuntime(1394): at java.lang.reflect.Method.invokeNative(Native Method)
02-20 11:44:56.103: E/AndroidRuntime(1394): at java.lang.reflect.Method.invoke(Method.java:521)
02-20 11:44:56.103: E/AndroidRuntime(1394): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
02-20 11:44:56.103: E/AndroidRuntime(1394): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
02-20 11:44:56.103: E/AndroidRuntime(1394): at dalvik.system.NativeStart.main(Native Method)
02-20 11:44:56.613: W/jdwp(1394): Debugger is telling the VM to exit with code=1
做回复,谢谢