应用程序崩溃了。不幸的是,该应用已停止工作

时间:2014-11-20 21:25:17

标签: java android google-maps-api-3

应用无法加载:不幸的是,该应用已停止

manifest资源配置文件

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.wptrafficanalyzer.proximitymapv2"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="20" />

<permission
      android:name="in.wptrafficanalyzer.proximitymapv2.permission.MAPS_RECEIVE"
      android:protectionLevel="signature"/>

<uses-permission android:name="in.wptrafficanalyzer.proximitymapv2.permission.MAPS_RECEIVE"/>

<uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <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:name="com.google.android.gms.version" 
    android:value="@integer/google_play_services_version"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="in.wptrafficanalyzer.proximitymapv2.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>

    <activity
        android:name=".ProximityActivity"
        android:label="@string/app_name" >
        <intent-filter >
            <action android:name="android.intent.action.PROXIMITY" />
     <!--       <action android:name="in.wptrafficanalyzer.activity.proximity"/> -->
            <category android:name="android.intent.category.DEFAULT" />            
        </intent-filter>
    </activity>

    <activity
        android:name=".NotificationView"
        android:label="@string/app_name" >

        <intent-filter >

            <category android:name="android.intent.category.DEFAULT" />            
            </intent-filter>

    </activity>


    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyCl6YaG8xxTQJe7R4LyGhf5kHqXG-mVrus"/>        

</application>

整个LogCat如下:

11-21 02:46:35.569: E/AndroidRuntime(27745): FATAL EXCEPTION: main
11-21 02:46:35.569: E/AndroidRuntime(27745): Process: in.wptrafficanalyzer.proximitymapv2, PID: 27745

11-21 02:46:35.569: E/AndroidRuntime(27745): java.lang.RuntimeException: Unable to instantiate application com.google.android.gms.version: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.version" on path: DexPathList[[zip file "/data/app/in.wptrafficanalyzer.proximitymapv2-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

11-21 02:46:35.569: E/AndroidRuntime(27745): at   android.app.LoadedApk.makeApplication(LoadedApk.java:563)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4491)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at android.app.ActivityThread.access$1500(ActivityThread.java:144)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at android.os.Handler.dispatchMessage(Handler.java:102)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at android.os.Looper.loop(Looper.java:135)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at android.app.ActivityThread.main(ActivityThread.java:5221)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at java.lang.reflect.Method.invoke(Native Method)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at java.lang.reflect.Method.invoke(Method.java:372)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

11-21 02:46:35.569: E/AndroidRuntime(27745): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.version" on path: DexPathList[[zip file "/data/app/in.wptrafficanalyzer.proximitymapv2-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

11-21 02:46:35.569: E/AndroidRuntime(27745):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at android.app.Instrumentation.newApplication(Instrumentation.java:979)

11-21 02:46:35.569: E/AndroidRuntime(27745):    at android.app.LoadedApk.makeApplication(LoadedApk.java:558)

11-21 02:46:35.569: E/AndroidRuntime(27745):    ... 10 more
11-21 02:46:35.569: E/AndroidRuntime(27745):    Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.version

11-21 02:46:35.569: E/AndroidRuntime(27745):        at java.lang.Class.classForName(Native Method)

11-21 02:46:35.569: E/AndroidRuntime(27745):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)

11-21 02:46:35.569: E/AndroidRuntime(27745):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)

11-21 02:46:35.569: E/AndroidRuntime(27745):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

11-21 02:46:35.569: E/AndroidRuntime(27745):        ... 13 more

11-21 02:46:35.569: E/AndroidRuntime(27745):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

2 个答案:

答案 0 :(得分:0)

检查清单

中的申请name
android:name="com.google.android.gms.version" 

只需从清单文件中的application标记中删除这两行

android:name="com.google.android.gms.version" 
android:value="@integer/google_play_services_version"

并将其放入meta-data代码

<meta-data
        android:name="com.google.android.gms.version" 
        android:value="@integer/google_play_services_version"/>

答案 1 :(得分:0)

GMS版本应该是meta-data代码中的application元素,而不是application代码。

对于android:name,{p> application引用了您的Application班级名称,但在代码中找不到该名称。

更改

<application
    android:name="com.google.android.gms.version" 
    android:value="@integer/google_play_services_version"
    ...>

    ...

</application>

类似

<application
    ...>

    ...

    <meta-data
        android:name="com.google.android.gms.version" 
        android:value="@integer/google_play_services_version"/>

</application>