Rachita Nanda
Rachita Nanda

Reputation: 4659

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.

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 stuck on "Gradle: resolve dependancies '_debugCompile'" or 'detachedConfiguration1'

How to add local .jar file dependency to build.gradle file?

Android Studio stuck on gradle resolving dependencies

gradle - not able to find dependencies from maven repo

Gradle cannot resolve dependencies in Android Studio

EDIT

I tried building from gradle command line also.

I also do sync project with gradle files

gradle command build

Please help!

Thanks

Upvotes: 2

Views: 5811

Answers (2)

Rachita Nanda
Rachita Nanda

Reputation: 4659

I found the solution to this problem here.

How do I add a library project to Android Studio?

How to add a jar in External Libraries in android studio

Solution-Add your jar file to app/libs and then right click the jar file and click "add as library".

After adding as library problem was resolved.

Upvotes: 1

isma3l
isma3l

Reputation: 3853

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 :

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

Upvotes: 1

Related Questions