首页 > 解决方案 > 当我尝试生成 APK 版本时出现问题

问题描述

当我尝试生成 APK 版本时,这个问题就出现了。

构建输出

“DuplicatePlatformClasses”类型问题的解释:有许多库不仅复制了 Android 平台的功能,而且使用了与 Android 中提供的完全相同的类名——例如 apache http 类。这可能会导致意外崩溃。

要解决此问题,您需要找到不再存在此问题的库的较新版本,或者使用 jarjar 工具之类的工具重新打包库(及其所有依赖项),或者最后重写代码以使用不同的API(例如,对于 http 代码,请考虑使用 HttpUrlConnection 或类似 okhttp 的库)。

 plugins {
    id 'com.android.application'
 }

    android  {
        packagingOptions{
            exclude 'META-INF/DEPENDENCIES'

        }
    compileSdkVersion 30
    buildToolsVersion "30.0.3"


 defaultConfig {
        applicationId "com.iza.letfly"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         vectorDrawables.useSupportLibrary = true
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
        }
    }


 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    }


 dependencies {


    implementation 'com.android.support:design:30.0.0'
    implementation 'android.arch.navigation:navigation-fragment:1.0.0'
    implementation 'android.arch.navigation:navigation-ui:1.0.0'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
     implementation 'androidx.preference:preference:1.1.1'
    implementation 'com.google.android.gms:play-services-ads:20.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.navigation:navigation-fragment:2.3.5'
    implementation 'androidx.navigation:navigation-ui:2.3.5'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation platform('com.google.firebase:firebase-bom:26.2.0')
    implementation 'com.google.api-client:google-api-client:1.31.2'
    implementation 'com.google.firebase:firebase-analytics'
     implementation 'com.google.firebase:firebase-core:19.0.0'
     implementation 'com.firebaseui:firebase-ui-auth:4.3.2'
     implementation 'com.firebaseui:firebase-ui-firestore:4.1.0'
    implementation 'com.google.firebase:firebase-auth:21.0.1'
     implementation 'com.facebook.android:facebook-android-sdk:4.42.0'
     implementation 'de.hdodenhof:circleimageview:3.1.0'
     implementation 'com.getbase:floatingactionbutton:1.10.1'
     implementation 'com.squareup.picasso:picasso:2.71828'
     implementation 'androidx.recyclerview:recyclerview:1.2.1'
     implementation 'com.google.http-client:google-http-client-gson:1.38.1'
     implementation 'com.squareup.okhttp3:okhttp:3.10.0'
     implementation 'com.google.firebase:firebase-storage:20.0.0'
     implementation 'com.google.firebase:firebase-database:20.0.0'
     implementation 'com.google.firebase:firebase-ads:20.2.0'
     implementation 'com.google.firebase:firebase-firestore:23.0.1'
     implementation 'com.android.billingclient:billing:4.0.0'
     implementation platform('com.google.firebase:firebase-bom:27.1.0')
     implementation 'com.google.firebase:firebase-messaging:22.0.0'
     testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

  }

 apply plugin: 'com.android.application'
 apply plugin: 'com.google.gms.google-services'

标签: androidandroid-studioapkrelease

解决方案


推荐阅读