2

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

Community
  • 1
  • 1
Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66
  • Can you build using the command line? (without Android Studio). It sounds like your dependencies are correctly defined in the Gradle DSL, but Android Studio failed to generate these confi .idea configuration files. – mdelolmo Jun 29 '15 at 17:30
  • I don't know how to build using command line. I'll try to build using cmd line – Rachita Nanda Jun 29 '15 at 17:42
  • Just run the gradle script (gradlew or gradle.bat, depending on your OS), which is probably on your project root folder (if you're using the gradle wrapper), and add the option "assemble". It is important to do that if you want to isolate your problem. – mdelolmo Jun 29 '15 at 17:48
  • use "gradle.bat build", to see if you can compile and build without errors, – mdelolmo Jun 30 '15 at 14:21

2 Answers2

1

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

isma3l
  • 3,833
  • 1
  • 22
  • 28
1

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.

Community
  • 1
  • 1
Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66