【问题标题】:Failed to implement ksoap2-android-assembly-2.4-jar-with-dependencies within Android Studio 3.5无法在 Android Studio 3.5 中实现 ksoap2-android-assembly-2.4-jar-with-dependencies
【发布时间】:2020-01-09 23:21:05
【问题描述】:

我正在开发一个 Android 应用程序项目。它基于 Web 服务和 SOAP 协议。我有 ksoap2-android-assembly-2.4-jar-with-dependencies.JAR 库,以便使用 SoapObject 等类。我把它放在libs目录下,设置为Library。

错误是

org.gradle.internal.exceptions.LocationAwareException:执行 任务“:app:javaPreCompileDebug”失败。 org.gradle.api.internal.artifacts.transform.TransformException: IdentityTransform 执行失败:D:\Android\All Crops 2019 年 5 月 3 日\xxxxxxx\app\libs\ksoap2-android-assembly-2.4-jar-with-dependencies.jar。

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation files('libs/ksoap2-android-assembly-2.4-jar-with-dependencies.jar')
    //implementation files('libs/ksoap2-android-assembly-3.5.0.jar')
    implementation 'com.android.support:cardview-v7:28.0.0'


}

【问题讨论】:

    标签: android android-gradle-plugin dependencies android-studio-3.5


    【解决方案1】:

    如果您使用不同的方法来引入 jar 依赖项,我采取以下步骤使其工作:

    • 我从here下载了...2.4-jar-with-dependencies.jar文件
    • 我验证了我的应用模块中存在 libs 文件夹,如下所示(如果不存在,则创建它):

    • 然后我将下载的文件粘贴到我的app/libs文件夹中,右键单击jar库并在列表底部单击Add as Library

    在它自动生成 gradle 依赖项后,我可以在我的 Activity 中访问和使用SoapObject


    我在运行 Android Studio 3.5 的 MacO 上,使用 androidx 而不是支持库:我使用的是 androidx.constraintlayout:constraintlayout:1.1.3 而不是 com.android.support.constraint:constraint-layout:1.1.3

    我的 gradle 发行版是 ...gradle-5.4.1-all.zip,在 build.gradle(项目)中,我使用的是 3.5.0:

    dependencies { classpath 'com.android.tools.build:gradle:3.5.0' }

    在 gradle.properties 中,我还设置了 android.useAndroidX=trueandroid.enableJetifier=true

    如果在执行了上述步骤之后(或者如果您已经这样做了),但仍然无法正常工作,您可能需要删除您的 .gradle 文件夹并重新构建。这可能是因为您将 Android Studio 更新到 3.5,但项目的 gradle 也没有更新。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-29
      • 2012-01-31
      • 1970-01-01
      • 1970-01-01
      • 2020-08-02
      • 2020-01-28
      相关资源
      最近更新 更多