Hello!
I can no longer find an absolutely valid Gradle configuration to reactivate my Project.
Android Studio Flamingo | 2022.2.1
I currently have the following build.gradle files:
build.gradle (:app):
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'io.realm.kotlin'
id 'kotlin-kapt'
}
android {
compileSdk 33
defaultConfig {
applicationId "com.cakeapp02"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
coreLibraryDesugaringEnabled true
}
kotlinOptions {
jvmTarget = '11'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.0'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
namespace 'com.cakeapp02'
}
/*
realm {
syncEnabled = true
}
*/
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
implementation 'androidx.fragment:fragment-ktx:1.5.7'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation "androidx.recyclerview:recyclerview:1.3.0"
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.code.gson:gson:2.8.9'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// Mongo Realm
implementation 'io.realm.kotlin:library-base:1.7.0' // Add to use local realm (no sync)
implementation 'io.realm.kotlin:library-sync:1.7.0'// Add to use Device Sync
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' // Add to use coroutines with the SDK
implementation "io.realm:android-adapters:4.0.0"
}
build.gradle (ProjectApp):
buildscript {
repositories {
google()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath 'io.realm.kotlin:gradle-plugin:1.7.1'
}
}
plugins {
id 'com.android.application' version '8.0.0' apply false
id 'com.android.library' version '8.0.0' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
id 'io.realm.kotlin' version '1.7.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
With this gradle configuration, I get an “Unresolved reference: init” in my AppActivity.kt.
import io.realm.*
import io.realm.kotlin.Realm
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_app)
Realm.init(this) // => Unresolved reference: init
...
}
I can’t find anywhere a runnable standard Gradle configuration with current drivers so that Realm.init(this) initializes without errors.
Does anyone know any advice or tips on what to change to get the project running again?
Axel