目录
一、java下引入objectBox
二、kotlin下引入objectBox
三、参考
1.build.gradle (project level):
buildscript { ext.objectboxVersion = '2.9.1' repositories { maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } } dependencies { classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion" } }
2.build.gradle (module level):
apply plugin: 'io.objectbox' // after applying Android plugin
3.增加一个entity
import io.objectbox.annotation.Entity; import io.objectbox.annotation.Id; @Entity public class Test { @Id long id; }
4.build项目,才能得到MyObjectBox类
1.build.gradle (project level):
buildscript { ext.kotlin_version = '1.4.31' ext.objectboxVersion = '2.8.1' repositories { maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion" } }
2.build.gradle (module level):
plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-android-extensions' } dependencies { implementation "io.objectbox:objectbox-android:$objectboxVersion" implementation "io.objectbox:objectbox-kotlin:$objectboxVersion" annotationProcessor "io.objectbox:objectbox-processor:$objectboxVersion" } apply plugin: 'io.objectbox' // after applying Android plugin
3.增加一个entity
import io.objectbox.annotation.Entity import io.objectbox.annotation.Id @Entity data class Note( @Id var id: Long = 0, var text: String? = null, var comment: String? = null )
4.build项目,才能得到MyObjectBox类
1.github不稳定 如何解决github.io访问不稳定问题?
2.java和kotlin语言互转
3.Android Studio 4.1 kotlin不能直接引用控件
4.Kotlin初体验(一)-引入Android Studio
5.ObjectBox数据库使用说明