Reputation: 12528
I just switched to android studio from eclipse (because of FB SDK), so this might be a stupid question. In my android project, I created a module (Java Library) which I call dbUtils, where I am using greenDAO to save data in SQLite. It requires an import
import android.content.Context;
It cannot find this class. I can't figure out what dependency I need to add. Under the :app module, this is recognized.
Upvotes: 1
Views: 1330
Reputation: 2591
You should use the android-library plugin in your build.gradle file. Take look here. This way the Android Studio will know that this project is an android library (not just a java one) and import the needed classes. I have used it and it works. Here is my build.gradle file
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 10
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':validationutils')
}
Upvotes: 1