java.lang.ClassNotFoundException:没找到类" com.google.android.gms.measurement.AppMeasurement"在路径上:DexPathList

时间:2017-08-11 18:25:45

标签: android android-viewpager admob

我的应用运行良好但现在崩溃了。即使我没有与firebase集成,我也开始收到警告。现在我觉得我无法解决这个问题。我尝试了stackoverflow上可用的所有可能的解决方案。此外,如果有帮助,我在我的代码中使用viewpager。

logcat的

 W/Ads: Invoke Firebase method getInstance error.
                                  java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.measurement.AppMeasurement" on path: DexPathList[[zip file "/data/app/com.kidsbox.android.abcforkidsalphabetshapesandnumbers-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kidsbox.android.abcforkidsalphabetshapesandnumbers-1/lib/arm, /vendor/lib, /system/lib]]
                                      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                      at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                      at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                      at com.google.android.gms.ads.internal.scionintegration.b.a(:com.google.android.gms.DynamiteModulesA:167)
                                      at com.google.android.gms.ads.internal.scionintegration.b.a(:com.google.android.gms.DynamiteModulesA:152)
                                      at com.google.android.gms.ads.internal.scionintegration.b.g(:com.google.android.gms.DynamiteModulesA:43)
                                      at com.google.android.gms.ads.internal.request.c.a(:com.google.android.gms.DynamiteModulesA:26)
                                      at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.DynamiteModulesA:4)
                                      at com.google.android.gms.ads.internal.util.af.call(:com.google.android.gms.DynamiteModulesA:3)
                                      at com.google.android.gms.ads.internal.util.ag.run(:com.google.android.gms.DynamiteModulesA:3)
                                      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
                                      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                      at java.lang.Thread.run(Thread.java:818)
                                    Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.measurement.AppMeasurement
                                      at java.lang.Class.classForName(Native Method)
                                      at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                      at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                      at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                            ... 13 more
                                   Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

清单

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kidsbox.android.abcforkidsalphabetshapesandnumbers">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Alphabet" />
    <activity android:name=".Number" />
    <activity android:name=".Shapes"/>
</application>

的build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.kidsbox.android.abcforkidsalphabetshapesandnumbers"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
 }

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services-ads:11.0.4'
testCompile 'junit:junit:4.12'
}

2 个答案:

答案 0 :(得分:0)

我认为此问题与How to enable multidexing with the new Android Multidex support library

类似
  1. 在build.gradle的依赖项中添加implementation "com.android.support:multidex:1.0.1"(可以用compile替换实现);
  2. 从Application扩展自定义应用程序。添加如下代码:

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(this)
    }
    
  3. 将您的自定义应用程序添加到AnroidManifest.xml中android:name=".CustomApplication"

答案 1 :(得分:0)

您应该使用compile&com; google.fire.firebase:firebase-ads:11.2.0&#39; 而不是编译com.google.android.gms:play-services-ads:11.2.0&#39;