在将项目迁移到 Android X 后,无法从构建>>构建捆绑包/APK(s)>>构建 Apk 创建 Apk

Cannot create Apk from Build>>Build Bundle(s) /APK(s)>>Build Apk(s) after Migrating project to Android X

我已经将我的项目迁移到 android x,我需要通过 android studio Build>>Build Bundle(s) /APK(s)>>Build Apk 创建项目的 Apk (s).但是当我这样做时,它会出现以下错误,如下面的屏幕截图所示: enter image description here

但是当我注释掉下面 build.gradle 文件中突出显示的部分时,如下图所示,构建是通过 Build>>Build Bundle(s) /APK(s)>>Build Apk 创建的(s) 过程 enter image description here

我已经尝试了互联网上的所有解决方案,例如使缓存无效并重新启动、清理项目并使用 androidComponent{ 而不是 android.applicationVariants.all {

任何帮助或任何解决此情况的方法都将不胜感激。

提前致谢:)

这是我的 build.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

//    dependencies {
//        classpath 'io.fabric.tools:gradle:1.25.4'
//    }
}
apply plugin: 'com.android.application'
//apply plugin: 'io.fabric'

android {
    signingConfigs {
        debug {
            storeFile file('D:\RAM MOBILE APPLICATION\keystore\debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    compileSdkVersion 28
    useLibrary 'org.apache.http.legacy'
    flavorDimensions "default"
    lintOptions{
        checkReleaseBuilds false
    }

    defaultConfig {
        applicationId "com.ram.courier"
        minSdkVersion 19
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 22
        signingConfig signingConfigs.debug
        vectorDrawables.useSupportLibrary = false
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        archivesBaseName = "RAMMobileUAT-2.9.60.apk"

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

    productFlavors {
        Uat {
            dimension "default"
            versionName "2.9.60"

//          External IP address UAT - for testing on winjit network
//          buildConfigField 'String', 'BASE_URL', '"http://41.21.176.123/rammobileweb/clientdataservice.asmx?wsdl"'
//          buildConfigField 'String', 'BASE_URL_MISSING_IMAGES', '"http://41.21.176.123/RAMMobileWeb/AndroidSessionSyncWS.asmx?wsdl"'
//          buildConfigField 'String', 'BASE_URL_EMAIL', '"http://41.21.176.123/RAMCSDPortalV3/DataServices/MobileDeviceIntegration.asmx?wsdl"'
//          buildConfigField 'String', 'BASE_URL_SYNC', '"http://41.21.176.123/RAM.Microservices.Mobile.API/api/v1.0/SessionSync/"'
//          buildConfigField 'String', 'BASE_URL_SYNC', '"https://azapp-rammobileservices-uat-001.azurewebsites.net/api/v1/SessionSync/"'

//          New URLS with Load balance setup
            buildConfigField 'String', 'BASE_URL', '"http://api.amss.uat.ram.co.za/RAMMobileWeb/ClientDataService.asmx?wsdl"'
            buildConfigField 'String', 'BASE_URL_MISSING_IMAGES', '"http://api.amss.uat.ram.co.za/RAMMobileWeb/AndroidSessionSyncWS.asmx?wsdl"'
            buildConfigField 'String', 'BASE_URL_EMAIL', '"http://api.amss.uat.ram.co.za/RAMCSDPortalV3/DataServices/MobileDeviceIntegration.asmx?wsdl"'
            buildConfigField 'String', 'BASE_URL_SYNC', '"http://api.amms.uat.ram.co.za/RAM.Microservices.Mobile.API/api/"'

            buildConfigField 'String', 'NAMESPACE', '"http://services.ramgroup.co.za/RAMMobileWeb"'
            buildConfigField 'String', 'NAMESPACEEMAIL', '"http://tempuri.org/"'

            buildConfigField 'String', 'GS_LICENSEKEY', '"533c5006525000010652015939525a0e4a1153091a555d4c105f511468090606570d5d530a0004"'

//          Application Insights keys dev  azapp-rammobileuserlogs-dev-001
//          manifestPlaceholders = [ AI_INSTRUMENTATION_KEY:"c3edea44-9226-4ebf-ab5b-03a2f51775e7"]

//          Application Insights keys UAT  azapp-rammobileuserlogs-uat-001
            manifestPlaceholders = [AI_INSTRUMENTATION_KEY: "b2ad4aa9-bec4-4c82-86c9-2d4d83bce331"]
            return void
        }
        Prod {
            dimension "default"
            versionName "1.28"

//          External IP address PROD - for testing on winjit network
//          buildConfigField 'String', 'BASE_URL', '"http://10.0.20.15/rammobileweb/clientdataservice.asmx?wsdl"'
//          buildConfigField 'String', 'BASE_URL_MISSING_IMAGES', '"http://10.0.20.15/RAMMobileWeb/AndroidSessionSyncWS.asmx?wsdl"'
//          buildConfigField 'String', 'BASE_URL_EMAIL', '"http://10.0.20.15/RAMCSDPortalV3/DataServices/MobileDeviceIntegration.asmx?wsdl"'
//          buildConfigField 'String', 'BASE_URL_SYNC', '"http://10.0.21.118/RAM.Microservices.Mobile.API/api/v1.0/SessionSync/"'

//          New URLS with Load balance setup
            buildConfigField 'String', 'BASE_URL', '"http://api.amss.ram.co.za/RAMMobileWeb/ClientDataService.asmx?wsdl"'
            buildConfigField 'String', 'BASE_URL_MISSING_IMAGES', '"http://api.amss.ram.co.za/RAMMobileWeb/AndroidSessionSyncWS.asmx?wsdl"'
            buildConfigField 'String', 'BASE_URL_EMAIL', '"http://api.amss.ram.co.za/RAMCSDPortalV3/DataServices/MobileDeviceIntegration.asmx?wsdl"'
            buildConfigField 'String', 'BASE_URL_SYNC', '"http://api.amms.ram.co.za/RAM.Microservices.Mobile.API/api/"'


            buildConfigField 'String', 'NAMESPACE', '"http://services.ramgroup.co.za/RAMMobileWeb"'
            buildConfigField 'String', 'NAMESPACEEMAIL', '"http://tempuri.org/"'

            buildConfigField 'String', 'GS_LICENSEKEY', '"533c5006525000010652015939525a0e4a1153091a555d4c105f511468090606570d5d530a0004"'

//          Application Insights keys PROD azapp-rammobileuserlogs-prod-001
            manifestPlaceholders = [AI_INSTRUMENTATION_KEY: "917c7651-6f2a-4cbe-bbe2-dc10d34273ec"]
            return void
        }
    }


//    android.applicationVariants.all { variant ->
//        variant.outputs.all { output ->
//            outputFileName = "RAMMobile_${variant.name}-${variant.versionName}.apk"
//        }
//    }
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
        google()
    }
    splits {
        abi {
            // Enables building multiple APKs per ABI.
            enable true
            // By default all ABIs are included, so use reset() and include to specify that we only
            // want APKs for x86 and x86_64.
            // Resets the list of ABIs that Gradle should create APKs for to none.
            reset()
            // Specifies a list of ABIs that Gradle should create APKs for.
            include "arm64-v8a"
            // Specifies that we do not want to also generate a universal APK that includes all ABIs.
            universalApk true
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
//    implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') { //log crash
//        transitive = true
//    }
    //noinspection GradleCompatible
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0' //Circular image view
    testImplementation 'junit:junit:4.12'
    implementation files('libs/ksoap2-android-assembly-3.0.0-RC.2-jar-with-dependencies.jar')
    implementation 'com.journeyapps:zxing-android-embedded:3.6.0' //Scanning barcode
    implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0' //Touch listener animation
    implementation 'org.chalup.microorm:microorm:0.8.0' //Access objects
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-analytics:16.0.0'
    implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'me.relex:circleindicator:1.2.2@aar' //Viewpager indicator
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
    implementation 'com.google.code.gson:gson:2.8.0'
    implementation project(':silky-signature')
    implementation 'com.github.jkwiecien:EasyImage:1.3.1' //Capture image
    implementation 'com.karumi:dexter:5.0.0' //Handling dangerous permissions

    implementation 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'

//    //Microsoft Azure Application Insight
    implementation 'com.microsoft.azure:applicationinsights-android:1.0-beta.10'

//    implementation 'com.thegrizzlylabs.geniusscan.sdk:gs-sdk:3.0.16'
    implementation 'com.geniusscansdk:gssdk-core:4.0.8'
//    implementation 'com.geniusscansdk:gssdk-ocr:4.0.8'

   implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.2.0'

    implementation 'androidx.fragment:fragment:1.0.0'
    //androidx support for tablayout
    implementation "com.google.android.material:material:1.4.0"

}

在此处输入代码

  1. 我想你已经很久没有更新你的应用了。

  2. 构建 gradle 个文件的语法已更改

  3. 创建一个新的应用程序并复制他们的构建 gradle 语法或检查其他人的应用程序
    源代码

通过制作 universalApk false!

解决了这个问题

之前确实如此。 :')