简体   繁体   English

Gradle-找不到依赖关系的Android Studio

[英]Gradle - dependencies not found Android Studio

I have added the dependencies in the gradle file but still the classes for the jar files are not recognized. 我已经在gradle文件中添加了依赖性,但是仍然无法识别jar文件的类。

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.devstring.imageframe"
        minSdkVersion 14
        targetSdkVersion 14
    }

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

dependencies {
    compile 'com.android.support:support-v4:18.0.0'

//    compile files('D:/EKCS-data/EDCloud/e.d.cloud/libs/activation.jar')
//    compile files('D:/EKCS-data/EDCloud/e.d.cloud/libs/activation.jar/additionnal.jar')
//    compile files('D:/EKCS-data/EDCloud/e.d.cloud/libs/activation.jar/mail.jar')
    compile fileTree(dir: 'libs', include: '*.jar')
}

I get error - cannot resolve class here 我收到错误-无法在这里解析课程

import javax.activation.DataHandler;
import javax.activation.DataSource;

    import javax.mail.Message;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;

I have already referred to the following 我已经提到了以下内容

Android Studio missing external dependencies Android Studio缺少外部依赖项

Android Studio stuck on "Gradle: resolve dependancies '_debugCompile'" or 'detachedConfiguration1' Android Studio卡在“ Gradle:解析依赖项'_debugCompile'”或“ detachedConfiguration1”上

How to add local .jar file dependency to build.gradle file? 如何将本地.jar文件依赖项添加到build.gradle文件?

Android Studio stuck on gradle resolving dependencies Android Studio卡在gradle解决依赖项上

gradle - not able to find dependencies from maven repo gradle-无法从Maven回购中找到依赖项

Gradle cannot resolve dependencies in Android Studio Gradle无法解析Android Studio中的依赖项

EDIT 编辑

I tried building from gradle command line also. 我也尝试从gradle命令行构建。

I also do sync project with gradle files 我也使用gradle文件同步项目

gradle命令构建

Please help! 请帮忙!

Thanks 谢谢

I think you are missing the [] , this is how i use it: 我认为您缺少[] ,这就是我的使用方式:

compile fileTree(dir: 'libs', include: ['*.jar'])

If that don't work, you could try using the ones from maven central : 如果那不起作用,您可以尝试使用来自Maven Central的:

compile 'javax.mail:mail:1.4.7'

That's the latest stable version, there is a beta, or choose an older veersion from http://mvnrepository.com/artifact/javax.mail/mail 那是最新的稳定版本,有测试版,或者从http://mvnrepository.com/artifact/javax.mail/mail选择较旧的版本

I found the solution to this problem here. 我在这里找到了解决此问题的方法。

How do I add a library project to Android Studio? 如何将库项目添加到Android Studio?

How to add a jar in External Libraries in android studio 如何在Android Studio的外部库中添加jar

Solution-Add your jar file to app/libs and then right click the jar file and click "add as library". 解决方案-将您的jar文件添加到app / libs,然后右键单击jar文件,然后单击“添加为库”。

After adding as library problem was resolved. 添加为库后,问题得以解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM