With new Room, How to highlight SQL Syntax in Dao
Interfaces?
For example @Query(SELECT * FROM user)
is it possible to highlight the words SELECT, FROM
with a different color and text format than the word user
?
With new Room, How to highlight SQL Syntax in Dao
Interfaces?
For example @Query(SELECT * FROM user)
is it possible to highlight the words SELECT, FROM
with a different color and text format than the word user
?
I found the answer from this link
I do not know why but if you are using kotlin-dsl (gradle ktx)
and implement dependencies with buildSrc
on build.gradle
file like this (object reference):
implementation(Dependencies.AndroidX.room)
implementation(Dependencies.AndroidX.roomKtx)
kapt(Dependencies.AndroidX.roomCompiler)
implementation(Dependencies.AndroidX.roomPaging)
That causes to not indexing (highlight or autocomplete) Android Room SQL
Scripts, so when I tried to implement with directly using String
like this:
val roomVersion = "2.4.2"
implementation("androidx.room:room-runtime:$roomVersion")
implementation("androidx.room:room-ktx:$roomVersion")
implementation("androidx.room:room-common:$roomVersion")
implementation("androidx.room:room-paging:$roomVersion")
kapt("androidx.room:room-compiler:$roomVersion")
that worked for me.
11.0.11
to 11.0.15.1
build.gradle.kts (project)
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath(BuildProject.GradlePlugins.androidNavigation)
classpath(BuildProject.GradlePlugins.hilt)
}
}
plugins {
id("com.android.application") version "7.2.1" apply false
id("com.android.library") version "7.2.1" apply false
id("org.jetbrains.kotlin.android") version "1.7.10" apply false
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
build.gradle.kts (module)
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-parcelize")
id("kotlin-android")
id("kotlin-kapt")
id("androidx.navigation.safeargs.kotlin")
id("dagger.hilt.android.plugin")
}
android {
compileSdk = BuildApplication.compileSdk
defaultConfig {
applicationId = BuildApplication.applicationId
minSdk = BuildApplication.minSdk
targetSdk = BuildApplication.targetSdk
versionCode = BuildApplication.versionCode
versionName = BuildApplication.versionName
testInstrumentationRunner = BuildApplication.androidTestInstrumentation
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true
javaCompileOptions {
annotationProcessorOptions {
argument("room.schemaLocation", "$projectDir/schemas")
}
}
}
buildFeatures {
dataBinding = true
viewBinding = true
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
multiDexEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
getByName("debug") {
isMinifyEnabled = false
multiDexEnabled = true
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
}
dependencies {
...
val roomVersion = "2.4.2"
implementation("androidx.room:room-runtime:$roomVersion")
implementation("androidx.room:room-ktx:$roomVersion")
implementation("androidx.room:room-common:$roomVersion")
implementation("androidx.room:room-paging:$roomVersion")
kapt("androidx.room:room-compiler:$roomVersion")
...
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
}
kapt {
correctErrorTypes = true
}
© 2022 - 2024 — McMap. All rights reserved.