1

I have this same problem - How to reference an external jar in an Android Library project in IntelliJ v10

...but the solution does not work for me. I keep getting this error

 E/AndroidRuntime: FATAL EXCEPTION: main
        java.lang.NoClassDefFoundError: com.loopj.android.http.RequestParams

I am using the new Android Studio (based on IntelliJ) and these are my settings - http://cl.ly/image/0t0Q26423w3R

Community
  • 1
  • 1
kapso
  • 11,703
  • 16
  • 58
  • 76
  • I'm having the same issue trying to add the jtwitter library to my project. This may be a bug with Android Studio. I have submitted a report to Google. – Matt May 21 '13 at 15:53

2 Answers2

0

I found this partial solution in another thread, but I figured I'd share it here also.

Make sure you modify build.gradle (located in your src folder) to look like this:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
    /****************************
        ADDITIONAL LIBRARIES HERE
     ****************************/
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 5
        targetSdkVersion 16
    }
}
Matt
  • 6,993
  • 4
  • 29
  • 50
-1

File -> Project Structure.

If you just have the jar

Add it Libraries or Global Libraries as you may require.

JoeHz
  • 2,136
  • 1
  • 18
  • 29
  • 1
    I tried but it doesnt work - http://cl.ly/image/3Q3a1E3m201e , http://cl.ly/image/0L2e2p3T3m0e – kapso May 20 '13 at 06:39
  • Two things. 1- I would not put the .jar in the path of your project. I generally keep a separate directory structure for external libs and import it from there. You also shouldnt have to "export" it. 2) What does the IDE show on the import directive or code that's trying to use the class in question.. Is there an error indicated? and if so, ddoes right clicking on it give you a suggested fix? – JoeHz May 20 '13 at 10:44