-
Notifications
You must be signed in to change notification settings - Fork 306
Description
Issue Basics
- ObjectBox version: 1.2.0-RC
- Reproducibility: always
Reproducing the bug
Description
I have a project set up with the following modules:
-mobile (application)
-shared (library)
-wear (application)
I have a single entity taken directly from the kotlin example "Note.kt" Originally I placed this in the shared module so that I could use the same entities in the mobile and wear application, but after building the project it complains -> "Unresolved reference: MyObjectBox"
When I moved Note.kt into the mobile app and build, it recognizes MyObjectBox fine.
Code
build.gradle (mobile)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.objectbox'
apply plugin: 'kotlin-android-extensions
android {
compileSdkVersion 27
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.grant.gradechaser"
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
wearApp project(':wear')
compile "com.android.support:appcompat-v7:$rootProject.ext.supportVersion"
compile "com.android.support:support-v4:$rootProject.ext.supportVersion"
compile "com.android.support:design:$rootProject.ext.supportVersion"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
mavenCentral()
}
build.gradle (shared)
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.objectbox'
// Until the ObjectBox Gradle plugin has better support for Kotlin, we must help it a bit:
//task('compileKotlin').dependsOn objectbox
android.sourceSets.main.java.srcDirs += 'build/generated/source/objectbox'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:$rootProject.ext.supportVersion"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "io.objectbox:objectbox-android:$objectboxVersion"
compile "io.objectbox:objectbox-kotlin:$objectboxVersion" // some useful Kotlin extension functions
kapt "io.objectbox:objectbox-processor:$objectboxVersion" // When using Kotlin use kapt instead:
}
repositories {
mavenCentral()
}
The wear build.gradle looks pretty similar to the mobile one, so I didn't include it.
I've tried putting the lines that add the generated code to the sourceSet in the mobile module too but that didn't fix the problem.
Is this module setup not supported?
I saw that you mentioned here
As a rule of thumb, they should reside in a single module. You could have multiple modules with entities, but only if they are totally separated (also different DB file).
But if they are all in the shared module, should that still work?