我有一个应用程序,当我将android studio更新到3.4.2版本并更新gradle
时,无论如何,我不得不强行更改某些库,例如将androidx
用到appcomaptibility
和注释中,之后,应用程序的同步没有任何问题,但是当我想在设备上运行应用程序时,出现以下错误。我进行搜索,将Java版本添加到gradle
等,但没有成功,再次出现相同的错误。我该如何解决这个问题?
错误:仅从Android O(--min-api 26)开始支持MethodHandle.invoke和MethodHandle.invokeExact
gradle
的ORMDroid库:
buildscript {
ext.java_version = JavaVersion.VERSION_1_8
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.0.2'
}
}
apply plugin: 'android-library'
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
}
android {
compileOptions {
sourceCompatibility java_version
targetCompatibility java_version
}
compileSdkVersion 16
buildToolsVersion '28.0.3'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
androidTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
defaultConfig {
minSdkVersion 16
}
}
repositories {
google()
}
gradle
我的应用程序:
buildscript {
ext.java_version = JavaVersion.VERSION_1_8
repositories {
jcenter()
google()
maven{
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.0.2'
classpath 'io.fabric.tools:gradle:1.30.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
dependencies {
//implementation 'com.google.firebase:firebase-core:11.0.4'
implementation fileTree(include: '*.jar', dir: 'libs')
implementation project(':ORMDroid')
implementation 'com.android.support:support-v4:29.1.0'
implementation 'com.android.support:cardview-v7:29.1.0'
implementation files('libs/javax.mail.jar')
implementation files('libs/additionnal.jar')
implementation files('libs/activation.jar')
implementation 'com.android.support:appcompat-v7:29.1.0'
implementation 'com.android.support:support-compat:29.1.0'
//noinspection GradleCompatible
//implementation 'com.google.android.ginstrumentTestms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8'
implementation 'com.android.support:support-annotations:29.1.0'
implementation 'org.codehaus.groovy:groovy-all:2.4.15'
}
android {
compileSdkVersion 29
buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility java_version
targetCompatibility java_version
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
androidTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instancem, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
defaultConfig {
applicationId 'com.test.test'
minSdkVersion 16
targetSdkVersion 29
versionCode 104
versionName "1.0.4"
}
}
//apply plugin: 'com.google.gms.google-services'
allprojects {
repositories {
google()
maven {
url 'https://maven.google.com/'
}
}
}
答案 0 :(得分:0)
不确定是否仍然有用,但是在这种情况下,您只需要在等级中更新minSdkVersion。
Android O要求minSdkVersion为26,因此您可以照此更新。
minSdkVersion 26