当我打电话给 realm.where(MessageEventModel::class.java).findAll()
抛出异常:这是错误
java.lang.IllegalArgumentException: MessageEventModel is not part of the schema for this Realm
at io.realm.internal.modules.CompositeMediator.getMediator(CompositeMediator.java:172)
at io.realm.internal.modules.CompositeMediator.getTableName(CompositeMediator.java:90)
Run Code Online (Sandbox Code Playgroud)
这是我的Application类
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
Realm.init(this)
val realmConfiguration = RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name("my_db")
.build()
Realm.setDefaultConfiguration(realmConfiguration)
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的境界模型
class MessageEventModel : RealmObject{
constructor()
var message = ""
constructor(message: String) : this(){
this.message = message
}
}
Run Code Online (Sandbox Code Playgroud)
这是我正在尝试检索模型的地方
class AwesomeChatFragment : Fragment() {
private val realm: Realm by lazy { Realm.getDefaultInstance() }
private var notifications: RealmResults<MessageEventModel>? = null …Run Code Online (Sandbox Code Playgroud) 我是scala世界的新手(来自android世界),我用play-framework创建了scala项目,一切正常,我需要添加数据库,为此我决定选择光滑,但是当我试图添加时像这样的依赖
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.1.0",
"org.slf4j" % "slf4j-nop" % "1.6.4"
)
Run Code Online (Sandbox Code Playgroud)
我收到此错误日志
Error:Error while importing SBT project:<br/>...<br/><pre>[info] Resolving com.typesafe#jse_2.10;1.2.3 ...
[info] Resolving org.scala-sbt#run;0.13.15 ...
[info] Resolving org.scala-sbt.ivy#ivy;2.3.0-sbt-48dd0744422128446aee9ac31aa356ee203cc9f4 ...
[info] Resolving com.typesafe.play#play-exceptions;2.6.5 ...
[info] Resolving org.scala-sbt#test-interface;1.0 ...
[info] Resolving com.jcraft#jsch;0.1.50 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.6 ...
[info] Resolving jline#jline;2.14.3 ...
[info] Resolving org.scala-sbt#compiler-ivy-integration;0.13.15 ...
[info] Resolving org.scala-sbt#incremental-compiler;0.13.15 ...
[info] Resolving org.scala-sbt#logic;0.13.15 ...
[info] Resolving com.typesafe#config;1.3.1 ...
[info] Resolving org.scala-sbt#main-settings;0.13.15 ...
[info] Resolving com.lightbend.play#play-file-watch_2.10;1.0.0 ...
[info] Resolving …Run Code Online (Sandbox Code Playgroud) 我正在遵循Fabric的官方文档来添加crashlytic,我已经成功地将所有内容添加到gradle.build文件中,但是现在当我尝试编写Fabric.with(this, new Crashlytics());
时说:
Error:(163, 31) error: cannot find symbol class Crashlytics
Error:(163, 9) error: cannot find symbol variable Fabric
Error:Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Run Code Online (Sandbox Code Playgroud)
这是我的gradle.build文件
....
apply plugin: 'io.fabric'
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com'
}
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
....
classpath 'io.fabric.tools:gradle:1.24.3'
}
}
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven {
url …Run Code Online (Sandbox Code Playgroud) 我播放声音有问题,当通知来时,通知显示,但没有声音或振动,我看到很多关于如何将声音和振动设置到通知频道的问题和答案,但它不起作用,这就是我正在尝试的方式
val pattern = longArrayOf(0, 200, 60, 200)
val chatSound = Uri.parse("${ContentResolver.SCHEME_ANDROID_RESOURCE}://" + context.packageName + "/" + R.raw.chat_alert)
val mBuilder = NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(title)
.setContentText(body)
val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val notification = mBuilder.build()
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
val mChanel = NotificationChannel(CHANNEL_ID, "test", NotificationManager.IMPORTANCE_HIGH)
val audioAttributes = AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build()
mChanel.setSound(chatSound, audioAttributes)
mChanel.enableVibration(true)
mChanel.enableLights(true)
mChanel.vibrationPattern = pattern
mNotificationManager.createNotificationChannel(mChanel)
}
mNotificationManager.notify(i, notification)
Run Code Online (Sandbox Code Playgroud)
我正在为 Android Pie 测试它
targetSdkVersion 28
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Rx方式使用房间从数据库中检索数据.这就是我试图这样做的方式
override fun onStart() {
super.onStart()
disposable.add(presenter.getAllBooks()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
println(it.size())
}))
}
Run Code Online (Sandbox Code Playgroud)
这是getAllBooks()演示者内部的方法
fun getAllBooks() : Flowable<List<Book>> {
val isMainThread = Looper.myLooper() == Looper.getMainLooper()
if (!isMainThread) {
updateBooks()
return db.bookDao().allBooks
}
return Flowable.empty()
}
Run Code Online (Sandbox Code Playgroud)
这里isMainThread变量总是true,我也试过observeOn(Shcedulers.io()),但同样的问题.
android ×4
kotlin ×3
android-room ×1
crashlytics ×1
java ×1
realm ×1
rx-android ×1
rx-java2 ×1
sbt ×1
scala ×1
slick-3.0 ×1