gpt4 book ai didi

java - Gradle Android 错误 : MethodHandle. 调用和 MethodHandle.invokeExact

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:09:04 26 4
gpt4 key购买 nike

我正在尝试在我的 Android 应用程序中使用 SOAP 服务。我正在尝试关注 this guide .当我尝试运行我的应用时出现错误:

Error: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)

我在 Android N(SDK 25 - 我不能像错误消息指示的那样跳到 26),这是一个由 Android Studio 刚刚创建的全新项目。

这是我没有更改的项目 build.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:3.4.1'

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

allprojects {
repositories {
google()
jcenter()
}
}

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

这是我的应用程序 build.gradle 文件:

apply plugin: 'com.android.application'

configurations {
jaxb
}

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
}
}

apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

repositories {
mavenCentral()
}

// tag::wsdl[]
task genJaxb {
ext.sourcesDir = "${buildDir}/generatedjava/jaxb"
ext.classesDir = "${buildDir}/classes/jaxb"
ext.schema = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx?ver=2017-10-01"

outputs.dir classesDir

doLast() {
project.ant {
taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask",
classpath: configurations.jaxb.asPath
mkdir(dir: sourcesDir)
mkdir(dir: classesDir)

xjc(destdir: sourcesDir, schema: schema,
package: "hello.wsdl") {
arg(value: "-wsdl")
produces(dir: sourcesDir, includes: "**/*.java")
}

javac(destdir: classesDir, source: 1.8, target: 1.8, debug: true,
debugLevel: "lines,vars,source",
classpath: configurations.jaxb.asPath) {
src(path: sourcesDir)
include(name: "**/*.java")
include(name: "*.java")
}

copy(todir: classesDir) {
fileset(dir: sourcesDir, erroronmissingdir: false) {
exclude(name: "**/*.java")
}
}
}
}
}
// end::wsdl[]

android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.magicmirror"
minSdkVersion 25
targetSdkVersion 29
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 'META-INF/spring.tooling'
exclude 'META-INF/spring.handlers'
exclude 'META-INF/spring-configuration-metadata.json'
exclude 'META-INF/additional-spring-configuration-metadata.json'
exclude 'META-INF/spring.factories'
exclude 'META-INF/spring.schemas'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation "org.springframework.boot:spring-boot-starter"
implementation "org.springframework.ws:spring-ws-core"
implementation(files(genJaxb.classesDir).builtBy(genJaxb))

jaxb "com.sun.xml.bind:jaxb-xjc:2.1.7"
}

根据日志,导致此问题的确切 JAR 是 org.springframework/spring-core/5.1.8.RELEASE.jar。添加 compileOptions block 在其他答案中提到作为修复,但它没有解决这个问题。我该如何解决这个问题?

最佳答案

你试过ksoap吗?

https://github.com/simpligility/ksoap2-android

看起来它应该做 soap,是活的并且适用于 android。

The ksoap2-android project provides a lightweight and efficient SOAP client library for the Android platform.

关于java - Gradle Android 错误 : MethodHandle. 调用和 MethodHandle.invokeExact,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56931092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com