0

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

在此处输入图像描述

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

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

我在项目中添加了模块,并在应用程序的 build.gradel 中的依赖项中配置了它,如下所示:

在此处输入图像描述

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

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')

       }

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

4

1 回答 1

0

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

于 2021-02-26T09:08:40.357 回答