编译时程序中没有错误。但是当它运行时会出现log cat错误并且应用程序崩溃了。
注意:我没有生成API密钥是否必须放置我自己的api密钥。我已经使用了我在教程中找到的api密钥,我指的是构建这个应用程序。
这是我的Log cat
12-23 14:56:49.560: W/dalvikvm(10858): Unable to resolve superclass of Lin/wptrafficanalyzer/locationmarkermysql/MainActivity; (6)
12-23 14:56:49.560: W/dalvikvm(10858): Link of class 'Lin/wptrafficanalyzer/locationmarkermysql/MainActivity;' failed
12-23 14:56:49.570: D/AndroidRuntime(10858): Shutting down VM
12-23 14:56:49.570: W/dalvikvm(10858): threadid=1: thread exiting with uncaught exception (group=0xb3a58ba8)
12-23 14:56:49.660: E/AndroidRuntime(10858): FATAL EXCEPTION: main
12-23 14:56:49.660: E/AndroidRuntime(10858): Process: in.wptrafficanalyzer.locationmarkermysql, PID: 10858
12-23 14:56:49.660: E/AndroidRuntime(10858): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{in.wptrafficanalyzer.locationmarkermysql/in.wptrafficanalyzer.locationmarkermysql.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "in.wptrafficanalyzer.locationmarkermysql.MainActivity" on path: DexPathList[[zip file "/data/app/in.wptrafficanalyzer.locationmarkermysql-1.apk"],nativeLibraryDirectories=[/data/app-lib/in.wptrafficanalyzer.locationmarkermysql-1, /system/lib]]
12-23 14:56:49.660: E/AndroidRuntime(10858): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
12-23 14:56:49.660: E/AndroidRuntime(10858): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
12-23 14:56:49.660: E/AndroidRuntime(10858): at android.app.ActivityThread.access$800(ActivityThread.java:135)
12-23 14:56:49.660: E/AndroidRuntime(10858): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
12-23 14:56:49.660: E/AndroidRuntime(10858): at android.os.Handler.dispatchMessage(Handler.java:102)
12-23 14:56:49.660: E/AndroidRuntime(10858): at android.os.Looper.loop(Looper.java:136)
12-23 14:56:49.660: E/AndroidRuntime(10858): at android.app.ActivityThread.main(ActivityThread.java:5001)
12-23 14:56:49.660: E/AndroidRuntime(10858): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 14:56:49.660: E/AndroidRuntime(10858): at java.lang.reflect.Method.invoke(Method.java:515)
12-23 14:56:49.660: E/AndroidRuntime(10858): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
12-23 14:56:49.660: E/AndroidRuntime(10858): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
12-23 14:56:49.660: E/AndroidRuntime(10858): at dalvik.system.NativeStart.main(Native Method)
12-23 14:56:49.660: E/AndroidRuntime(10858): Caused by: java.lang.ClassNotFoundException: Didn't find class "in.wptrafficanalyzer.locationmarkermysql.MainActivity" on path: DexPathList[[zip file "/data/app/in.wptrafficanalyzer.locationmarkermysql-1.apk"],nativeLibraryDirectories=[/data/app-lib/in.wptrafficanalyzer.locationmarkermysql-1, /system/lib]]
12-23 14:56:49.660: E/AndroidRuntime(10858): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-23 14:56:49.660: E/AndroidRuntime(10858): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
12-23 14:56:49.660: E/AndroidRuntime(10858): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
12-23 14:56:49.660: E/AndroidRuntime(10858): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
12-23 14:56:49.660: E/AndroidRuntime(10858): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
12-23 14:56:49.660: E/AndroidRuntime(10858): ... 11 more
这是我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.wptrafficanalyzer.locationmarkermysql"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<!-- Protect the map component of the application using application signature -->
<permission
android:name="in.wptrafficanalyzer.locationmarkermysql.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<!-- Allows to receive map -->
<uses-permission android:name="in.wptrafficanalyzer.locationmarkermysql.permission.MAPS_RECEIVE" />
<!-- Used by the Google Maps Android API V2 to download map tiles from Google Maps servers -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Allows the Google Maps Android API V2 to cache map tile data in the device's external storage area -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Allows the Google Maps Android API V2 to use WiFi or mobile cell data (or both) to determine the device's location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Allows the Google Maps Android API V2 to use the Global Positioning System (GPS)
to determine the device's location to within a very small area -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Allows to contact Google Serves -->
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- Google Maps Android API V2 requires OpenGL ES version 2 -->
<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" >
<activity
android:name="in.wptrafficanalyzer.locationmarkermysql.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>
<!-- Specifies the Android API Key, which is obtained from Google API Console -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_ANDROID_API_KEY" />
</application>
</manifest>