android - 类未找到异常 : unable to find class "android.support.v4.util.ArrayMap"

标签 android firebase-authentication bluetooth-lowenergy barcode-scanner crashlytics-android

我的应用程序的签名 apk 在高于 5.0.1 的 Android 版本上运行,但我面临这个问题,即我的应用程序在版本 5.0.1 上启动应用程序后立即崩溃,这是我收到的错误 - 原因:java.lang.ClassNotFoundException:在路径上找不到类“android.support.v4.util.ArrayMap”:DexPathList[[zip 文件“/data/app/com.*****1”/base.apk"],nativeLibraryDirectories=[/vendor/lib,/system/lib]]

请注意,当我使用 android studio 运行时,该应用程序不会崩溃,但当我运行签名的 apk 时,它会崩溃。 我不知道该怎么办,我已经浏览了很多 stackoverflow 问题,但没有找到任何可以解决我的问题的方法。这是我的 app.gradle 文件 -

**buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' } // for crashlytics
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
    compileSdkVersion 26
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "*****"
        minSdkVersion 21
        targetSdkVersion 26
        flavorDimensions "default"
        packagingOptions {
            exclude 'META-INF/rxjava.properties'
        }
        versionCode 3
        multiDexEnabled true
        versionName "1.0.3"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    android {
        lintOptions {
            checkReleaseBuilds false
            abortOnError false
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
    dexOptions {
        javaMaxHeapSize "2g"
    }
}
repositories {
    mavenCentral()
    google()
    maven { url 'https://maven.fabric.io/public' }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //google 's library
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.0.2'
    implementation 'com.android.support:design:26.0.2'
    implementation 'com.android.support:support-v4:26.0.2'
    implementation 'com.android.support:support-v13:26.0.2'
    implementation 'com.android.support:cardview-v7:26.0.2'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.google.android.gms:play-services-vision:11.8.0'

    //for barcode generation
    implementation 'com.google.zxing:core:3.2.0'
    implementation 'com.android.support:multidex:1.0.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    compile 'me.dm7.barcodescanner:zxing:1.9'
    compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'

    //multidex support
    compile 'com.android.support:multidex:1.0.1'

    //for fancy dialogs
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.google.android.gms:play-services:11.8.0'
    compile 'com.geniusforapp.fancydialog:FancyDialog:0.1.4'

    //for home screen carousal view
    compile 'com.synnapps:carouselview:0.1.4'

    //for bottom navigation
    compile 'com.ss.bottomnavigation:bottomnavigation:1.5.2'

    //for shaping the image view
    compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
    compile 'com.jackandphantom.android:circularimageview:1.2.0'

    //libraries for retrofit and conversion factory GSON
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.google.code.gson:gson:2.8.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'

    //FilePicker Library
    compile 'com.droidninja:filepicker:2.0.8'

    //for welcome screen
    compile 'com.stephentuso:welcome:1.4.1'
    compile 'com.squareup.okhttp3:okhttp:3.9.1'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.0.1'
    compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
    compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    compile 'com.squareup.okhttp3:okhttp:3.3.1'

    //material calender picker
    compile 'com.wdullaer:materialdatetimepicker:3.4.0'


    implementation 'com.trello:rxlifecycle:1.0'
    implementation 'com.trello:rxlifecycle-components:1.0'
    compile 'com.polidea.rxandroidble:rxandroidble:1.4.3'
    implementation 'com.android.support:design:26.0.2'
    compile 'io.reactivex.rxjava2:rxjava:2.0.7'

    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

    //libraries for firebase integration
    //for analytics
    compile 'com.google.firebase:firebase-core:11.8.0'

    //for cloud messenging
    compile 'com.google.firebase:firebase-messaging:11.8.0'

    //for circular indicator
    compile 'com.github.lzyzsd:circleprogress:1.2.1'
    compile 'me.biubiubiu.justifytext:library:1.1'
    implementation files('libs/imagecapture.jar')
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
}
apply plugin: 'com.google.gms.google-services'**

这是我的 build.gradle(项目级别)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.1.0'
        classpath 'io.fabric.tools:gradle:1.25.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://jitpack.io"

        }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

最佳答案

如果 gradle 版本是 3.x.x 尝试添加 maven { url 'https://maven.google.com' }

allprojects {
    repositories {
        //add here
    }
}

而不是 google() 和同步 gradle。应该有帮助。您可以使用 this link 看到它们之间的区别。

关于android - 类未找到异常 : unable to find class "android.support.v4.util.ArrayMap",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52872857/

相关文章:

android - cloudBackend.setCredential 未设置 CloudEntity 的 createdBy/updatedBy/owner 属性

ios - 我可以只从一个蓝牙广播多个 ibeacon 信号吗?如何

android - 使用低功耗蓝牙解锁 Linux

ios - 如果设备关闭,尝试在 IOS 应用程序中检索以前配对的蓝牙设备将不会响应失败

android - 当内容无法容纳时,如何创建默认形状为正方形且高度可自动调整的 TextView?

android - 应用程序启动期间的白色背景

Android 在 TextView 或 EditView 中选择一个词

javascript - Firebase 如何链接用电话号码创建的帐户

android - 在 firebase 应用程序中添加 sha1 失败并出现错误

android - 在 Android 应用程序中使用电子邮件 ID 和密码注册