Ksoap2 库到 android studio 错误消息,如何解决?

问题描述

我尝试使用 .jar 文件版本 3.6.4 在 android studio 中导入 Ksoap2 库。我已经成功地将 jar 文件实现到 android studio。但是,在我尝试导入时的模块应用程序活动中,例如导入“org.ksoap2.soapEnvelope;”,它得到并错误显示以下结果:

任务“:app:checkDebugAarMetadata”执行失败。

无法解析配置“:app:debugRuntimeClasspath”的所有文件。 找不到 com.google.code.ksoap2-android:ksoap2-android:3.6.4。 在以下位置搜索: - https://repo.maven.apache.org/maven2/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom - https://dl.google.com/dl/android/maven2/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom - https://jcenter.bintray.com/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom 要求: 项目:应用

可能的解决方案:

导入库也有错误,请看图片

enter image description here

这是 Build.gradle 模块代码

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"


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

}

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

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

这是 Build.gradle(app) 模块代码

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsversion "30.0.3"

    defaultConfig {
        applicationId "com.kowloondairycompanykdl.milk_ic"
        minSdkVersion 27
        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
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation files('libs\\ksoap2-android-assembly-3.6.4.jar')
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    compile filetree(dir: 'libs',include: ['*.jar'])
    compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.4'

}

请帮助我,我被困在这里很长时间了。如何修复错误以及如何正确实现 Ksoap2 库。谢谢

解决方法

该库似乎没有 3.4.3 版本。有一个 3.4.0。最新的是3.6.4。您将需要使用其中之一。我会迁移到 3.6.4,因为 3.4.0 已经 5 年多了,而且可能缺少安全更新。