Reputation: 817
I have started with greendao 3.2. I added greendao jar in libs folder and added it as library. I generated my entities using greendao-generator. It generates entities but the generated entities java some annotations and android studio is giving error on these annotations.It is giving an error cannot find "org.greenrobot.greendao.annotation.*". How to resolve this?
Upvotes: 0
Views: 3685
Reputation: 4023
Probably you didn't add the library in your app module . First of all rather than using jar , you can use gradle dependency . In your generator project add the following dependency
compile 'org.greenrobot:greendao-generator:3.2.0'
So the gradle file of your generator module , should be look like this
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.greenrobot:greendao-generator:3.2.0'
}
And in your gradle file (module app) add the following
compile 'org.greenrobot:greendao:3.2.0'
Your main gradle file (module app) should be like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.tcs.a1003548.greendao"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'org.greenrobot:greendao:3.2.0'
}
Upvotes: 1
Reputation: 20258
Why are you putting .jar in libs
folder and not using Gradle
for dependency management? This quickly leads to dependency hell. It is a lot easier.
Inside main build.gradle
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.0'
}
}
Inside application build.gradle
:
apply plugin: 'org.greenrobot.greendao'
dependencies {
compile 'org.greenrobot:greendao:3.2.0'
}
Upvotes: 1