【发布时间】:2022-01-10 16:15:03
【问题描述】:
当我尝试构建 apk 或只是构建项目时,它给了我这个错误:
com.android.tools.r8.internal.m1: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
但是当我通过 USB 连接手机并手动运行应用程序时,它就可以正常工作了。
是的,我发现了几个类似的问题,但没有一个对我有用。
构建.gradle
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
机器人{ 编译SDK 31
defaultConfig {
applicationId "com.abhaysapp.vaccination"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
packagingOptions{
exclude 'com/itextpdf/io/font/cmap_info.txt'
exclude 'com/itextpdf/io/font/cmap/*'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
依赖{
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'com.google.firebase:firebase-database:20.0.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0-alpha03'
androidTestImplementation "io.mockk:mockk-android:1.9.0"
implementation 'com.airbnb.android:lottie:4.2.2'
androidTestImplementation 'androidx.test:rules:1.4.0-alpha05'
implementation 'com.orhanobut:dialogplus:1.11@aar'
implementation 'com.itextpdf:itext7-core:7.1.3';
implementation 'com.android.volley:volley:1.2.1'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
}
【问题讨论】:
-
当“我通过 USB 连接我的手机并手动运行应用程序”时它起作用的原因很可能是由于 Android Studio 在直接从 Android Studio 中调试时注入了所连接手机的
minSdk。
标签: android android-studio gradle build.gradle