应用程序未在Android 4.4中运行

时间:2018-05-24 13:04:04

标签: android google-cloud-messaging google-play-services

我正在使用下面的gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.radtek.dlms_detroit"
        minSdkVersion 19
        targetSdkVersion 22

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
        multiDexEnabled true
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}


dependencies {
    //compile project(':captureActivity')
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:design:23.0.0'
    compile 'com.android.support:multidex:1.0.1'

    compile files('libs/DataCollection.jar')
    compile files('libs/guice-3.0-no_aop.jar')
    compile files('libs/httpcore-4.3.2.jar')
    compile files('libs/httpmime-4.3.3.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/roboguice-2.0.jar')
    compile files('libs/volley.jar')
    compile files('libs/ZSDK_ANDROID_API.jar')
    compile 'com.google.android.gms:play-services-appindexing:8.1.0'
    // Include the Google Maps Android API from Google Play Services.
    compile 'com.google.android.gms:play-services-maps:8.1.0'
    compile 'com.google.android.gms:play-services-location:8.1.0'
    compile 'com.google.android.gms:play-services:8.1.0'

    compile files('libs/aspectjrt-1.7.3.jar')
    compile files('libs/isoparser-1.0.6.jar')
}

它正在构建正常,但它在启动时崩溃并带有以下堆栈跟踪:

Logcat错误:

05-24 18:16:19.765 4940-4940/com.radtek.dlms_detroit E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                                                                                 java.lang.RuntimeException: Unable to get provider com.google.android.gms.measurement.AppMeasurementContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.measurement.AppMeasurementContentProvider" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.radtek.dlms_detroit-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.radtek.dlms_detroit-2, /vendor/lib, /system/lib]]
                                                                           at android.app.ActivityThread.installProvider(ActivityThread.java:4793)
                                                                           at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)
                                                                           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)
                                                                           at android.app.ActivityThread.access$1500(ActivityThread.java:135)
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                           at android.os.Looper.loop(Looper.java:136)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:5017)
                                                                           at java.lang.reflect.Method.invokeNative(Native Method)
                                                                           at java.lang.reflect.Method.invoke(Method.java:515)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                                                           at dalvik.system.NativeStart.main(Native Method)
                                                                        Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.measurement.AppMeasurementContentProvider" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.radtek.dlms_detroit-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.radtek.dlms_detroit-2, /vendor/lib, /system/lib]]
                                                                           at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
                                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
                                                                           at android.app.ActivityThread.installProvider(ActivityThread.java:4778)
                                                                           at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385) 
                                                                           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325) 
                                                                           at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
                                                                           at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                           at android.os.Looper.loop(Looper.java:136) 
                                                                           at android.app.ActivityThread.main(ActivityThread.java:5017) 
                                                                           at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                           at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
                                                                           at dalvik.system.NativeStart.main(Native Method) 

还尝试了相关的堆栈问题:

1。Updating Play services from 8.1 to 8.3 with Proguard enabled

2。Error on some devices - couldn't find class 'com.google.android.gms.measurement.internal.zzz'

1 个答案:

答案 0 :(得分:0)

由于multidex无法正常工作,因此缺少某些类。您必须编辑Multidex的Application类才能在5.0之前工作。让它像这样扩展MuliDexApplication

public class MyApplication extends MultiDexApplication { ... }

或者,如果您没有应用程序类,请在清单中添加此内容

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
        android:name="android.support.multidex.MultiDexApplication" >
    ...
</application>