Home Features Docs Blog Support GitHub

Add moe-core.jar to common module


(Levino Moises) #1

I’m trying to add more-core to my common module, so I can use its android.database.sqlite for both Android and iOS platforms. Is that how it’s supposed to go, or the code in moe-core.jar is only supposed to be used in iOS?

I tried multiple different approaches for it:

Adding moe-core as a plugin to common gradle:

This one results in an error when adding the common module as a dependency to the Android app:

buildscript {
    repositories {
        jcenter()
        mavenLocal()
    }
    dependencies {
        classpath group: 'org.multi-os-engine', name: 'moe-gradle', version: '1.4.+'
    }
}

apply plugin: 'moe'

And simply adding the moe-core.jar to the common module under a lib folder and making it a dependency throws an error on the build phase(':ios:moeMainDebugX86Dex2Oat'):

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation files('libs/moe-core.jar')
}

(Alan Hamilton) #2

We have added a ‘compileOnly’ dependency in our shared module to moe-core.jar, at runtime the classes are resolved correctly on each platform.


(Levino Moises) #3

Thanks Alan! I will try that.

I also found a solution for it.

On my android common module I add the moe plugin, this way I don’t have to deal with .jar files:

buildscript {
    repositories {
        jcenter()
        mavenLocal()
    }
    dependencies {
        classpath group: 'org.multi-os-engine', name: 'moe-gradle', version: '1.4.+'
    }
}

apply plugin: 'moe'

And on my android module, I exclude ‘multi-os-engine’ dependencies, as it won’t be used there:

implementation(project(':common')) {
    exclude group: 'multi-os-engine'
}