我尝试了几次解决这个问题,我无法按照指南
https://developers.google.com/maps/documentation/android/start
但我无法解决这个问题任何人都知道这个错误请帮助我
这是活动>
package com.example.lifecycle;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.support.v4.app.FragmentActivity;
public class MainActivity extends android.support.v4.app.FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
这是 Xml
<?xml version="1.0" encoding="utf-8"?>
<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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
<fragment
android:id="@+id/fragment1"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"
android:name="com.testing.svma.MainActivity" />
</RelativeLayout>
——这很明显——
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lifecycle"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<permission
android:name="com.example.lifecycle.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.lifecycle.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxx" />
<activity
android:name="com.example.lifecycle.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>
</application>
I also reference my app to google-play-services_lib in eclipse.
but everytime, error report in logcat like this:
06-06 08:46:06.513: E/Trace(1136): error opening trace file: No such file or directory (2)
06-06 08:46:07.411: E/AndroidRuntime(1136): FATAL EXCEPTION: main
06-06 08:46:07.411: E/AndroidRuntime(1136): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.lifecycle/com.example.lifecycle.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.lifecycle.MainActivity" on path: /data/app/com.example.lifecycle-2.apk
06-06 08:46:07.411: E/AndroidRuntime(1136): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
06-06 08:46:07.411: E/AndroidRuntime(1136): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-06 08:46:07.411: E/AndroidRuntime(1136): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-06 08:46:07.411: E/AndroidRuntime(1136): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-06 08:46:07.411: E/AndroidRuntime(1136): at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 08:46:07.411: E/AndroidRuntime(1136): at android.os.Looper.loop(Looper.java:137)
06-06 08:46:07.411: E/AndroidRuntime(1136): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-06 08:46:07.411: E/AndroidRuntime(1136): at java.lang.reflect.Method.invokeNative(Native Method)
06-06 08:46:07.411: E/AndroidRuntime(1136): at java.lang.reflect.Method.invoke(Method.java:511)
06-06 08:46:07.411: E/AndroidRuntime(1136): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-06 08:46:07.411: E/AndroidRuntime(1136): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-06 08:46:07.411: E/AndroidRuntime(1136): at dalvik.system.NativeStart.main(Native Method)
06-06 08:46:07.411: E/AndroidRuntime(1136): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.lifecycle.MainActivity" on path: /data/app/com.example.lifecycle-2.apk
06-06 08:46:07.411: E/AndroidRuntime(1136): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
06-06 08:46:07.411: E/AndroidRuntime(1136): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-06 08:46:07.411: E/AndroidRuntime(1136): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-06 08:46:07.411: E/AndroidRuntime(1136): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
06-06 08:46:07.411: E/AndroidRuntime(1136): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
06-06 08:46:07.411: E/AndroidRuntime(1136): ... 11 more
谢谢你 -