首页 > 解决方案 > 应用程序未构建 apk - MethodHandle.invoke 和 MethodHandle.invokeExact 仅支持从 Android O (--min-api 26) 开始

问题描述

我的应用程序在我的 android 手机 (android 10) 上运行良好。但是当我尝试构建 apk 时,构建并没有发生。如果我将 minSdk 更改为 26,它会构建得很好。但我想将应用程序构建为 minSdk 21。我不知道确切的问题是什么。请帮帮我。

它显示此错误消息。 在此处输入图像描述

这是我的应用程序级 gradle 代码

plugins {
        id 'com.android.application'
    }
    
    android {
        compileSdkVersion 30
        buildToolsVersion '30.0.3'
    
        defaultConfig {
            applicationId "com.affable.ssmartbills"
            minSdkVersion 21
            targetSdkVersion 30
            versionCode 1
            versionName "1.0"
    
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
    
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    
    
        packagingOptions {
            exclude 'com/itextpdf/io/font/cmap_info.txt'
            exclude 'com/itextpdf/io/font/cmap/*'
        }
    
    
    }
    
    dependencies {
    
        implementation 'androidx.appcompat:appcompat:1.3.1'
        implementation 'com.google.android.material:material:1.4.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        testImplementation 'junit:junit:4.13.2'
        androidTestImplementation 'androidx.test.ext:junit:1.1.3'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    
        //animation
        implementation 'com.airbnb.android:lottie:3.6.1'
    
        //alternative for Shared-Pref
        implementation 'io.paperdb:paperdb:2.7.1'
    
        //Get SQLite from assets
        implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
    
        //custom Toast
        implementation 'com.github.GrenderG:Toasty:1.5.0'
    
        //file or folder chooser
        implementation 'com.github.hedzr:android-file-chooser:v1.2.0-final'
    
        //import export as excel file
        implementation 'com.ajts.androidmads.SQLite2Excel:library:1.0.4'
    
        //run time permission
        implementation 'com.karumi:dexter:6.2.2'
    
        //circle img view
        implementation 'de.hdodenhof:circleimageview:3.1.0'
    
        //Bar-Code Scanner
        //https://github.com/dm77/barcodescanner
        implementation 'me.dm7.barcodescanner:zxing:1.9.13'
    
        //Image-Picker
        //https://android-arsenal.com/details/1/7055
        implementation 'com.github.maayyaannkk:ImagePicker:1.0.9'
    
        //iText-7 library
        implementation 'com.itextpdf:itext7-core:7.1.3'
    
        //pdf viewer
        implementation 'com.github.barteksc:android-pdf-viewer:3.1.0-beta.1'
    
        //mp chart
        //https://github.com/PhilJay/MPAndroidChart
        implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    
    
    }

这是构建级别的gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2'

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

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

}

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

标签: android

解决方案


推荐阅读