Android realm supports Maven or has the latest resources of jar

I have a strange use case here. My project is divided into two modules, one is the server project and the other is @ L_ 403_ 0 @ - app. Now they all share the same model class. Use Maven build tool for server project in eclipse and gradle for Android App application in Android studio

It looks like a domain without Maven artifacts, and the latest version of the jar file was not found

Please help me find out the strange situation

resolvent:

You need to add some skill to the model to share between Android and shared server projects

You can create a virtual domain class for the server, which can be excluded by gradle, and you need to create the same and identical class in the same and identical package. Server class:

package io.realm;
import java.util.ArrayList;

public class RealmObject extends ArrayList
{

}

package io.realm;
import java.util.ArrayList;

public class RealmList<E> extends ArrayList
{

}

Shared project gradle should ignore virtual classes and can use domain classes:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath "io.realm:realm-gradle-plugin:2.0.2"
    }
}

repositories {
    mavenCentral()
    jcenter()
}

apply plugin: 'com.android.library'
apply plugin: 'realm-android'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"
    publishNonDefault true

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 24
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java {
                srcDirs 'src'
                //Exclude server (fake) Realm dependent files to avoid conflicts with Realm framework
                exclude '**/Ignore.java'
                exclude '**/RealmObject.java'
                exclude '**/RealmList.java'
                exclude '**/PrimaryKey.java'
            }
            res.srcDirs = ['res']
            aidl.srcDirs = ['aidl']
        }
    }

    lintOptions {
        abortOnError false
    }

    packagingOptions {
        exclude 'Meta-INF/DEPENDENCIES'
        exclude 'Meta-INF/LICENSE'
        exclude 'Meta-INF/LICENSE.txt'
        exclude 'Meta-INF/license.txt'
        exclude 'Meta-INF/NOTICE'
        exclude 'Meta-INF/NOTICE.txt'
        exclude 'Meta-INF/notice.txt'
        exclude 'Meta-INF/ASL2.0'
    }
}

Note: the server still does not support domain. We just adjust to support Android and server work

Final model:

import io.realm.RealmList;
import io.realm.RealmObject;

public class MyModel extends RealmObject

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>