错误:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

问题描述

我正在尝试在 Android Studio 上使用 sshj 开发 SFTP 客户端,以便应用程序可以通过 ssh 使用 SFTP 安全地连接到服务器。代码运行良好,但是当我添加“sshj-0.10.0”模块时,它给了我这个复杂的错误

enter image description here

使用 net 库运行服务器代码需要“sshj-0.10.0”模块,如下所示:

import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.sftp.SFTPClient;

我将模块添加到项目中,并在应用的 build.gradel 中的依赖项中进行了配置,如下所示:

enter image description here

到目前为止我尝试过的(但不限于):

1- 清理项目然后重建项目 - 失败

2- 使缓存无效/重新启动 - 失败

3- 从我的根项目中删除 .gradle 和 .idea- 失败

4- 添加

android {
    defaultConfig {
    multiDexEnabled true
      }
   }

dependencies {// Multidex
implementation 'com.android.support:multidex:1.0.3'
implementation project(path: ':sshj-0.10.0')
}

没有对我有用的解决方案。

这是我的 build.gradle(:app)

apply plugin: 'com.android.application'

 android {
    compileSdkVersion 28
     defaultConfig {
      applicationId "com.example.mohsenali.autosen"
    minSdkVersion 23
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
    release {
        proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
       }
    }
   }


  android {
     defaultConfig {
    multiDexEnabled true
     }
   }


    dependencies {
       implementation filetree(dir: 'libs',include: ['*.jar'])
       implementation 'com.android.support:appcompat-v7:28.0.0'
       implementation 'com.android.support.constraint:constraint-layout:2.0.2'
       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'
      //TedPermission
       implementation 'gun0912.ted:tedpermission:1.0.3'
       implementation files('D:/SKKU_PhD/Android/workspace_2018_projects/AutoSen/app/libs/commons-net-3.7.1.jar')
// Multidex
       implementation 'com.android.support:multidex:1.0.3'
       implementation project(path: ':sshj-0.10.0')

       }

我知道这种错误很流行,但我从两天前开始尝试了许多可用的 SO 解决方案,但没有一个我有帮助。 所以请不要将其标记为重复,也许有人可以提供帮助。谢谢。

解决方法

最后,我通过在“app”项目的根目录中创建“libs”文件夹解决了这个错误,并向其中添加了 .jar 库。之后,我通过添加以下行来更新“build.gradle(:app)”中的代码:“implementation files('path to/app/libs/jsch-0.1.55.jar')”。