I want to use realm.io for android application but I have problems during installation
here is my build.gradle (Module :app)
file
plugins {
id 'com.android.application'
}
android {
namespace 'com.example.ig'
compileSdk 33
defaultConfig {
applicationId "com.example.ig"
minSdk 28
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// for MongoDB
implementation "io.realm:realm-gradle-plugin:10.16.1"
}
I couldn't add these codes here this
apply plugin: 'realm-android'
realm {
syncEnabled = true
}
after this stage I wrote this code and this code
Realm.init(this); // context, usually an Activity or Application
app = new App(new AppConfiguration.Builder(appID)
.build());
and now getting an error message:
How can I resolve this error message?
I updated my build.gradle (Module :app)
file as follows and now the codes are recognized by Android Studio.
// START[for MongoDB Realm.io]
buildscript {
dependencies {
classpath "io.realm:realm-gradle-plugin:10.11.1"
}
}
// FINISH[for MongoDB Realm.io]
plugins {
id 'com.android.application'
}
// START[for MongoDB Realm.io]
apply plugin: "realm-android"
realm {
syncEnabled = true
}
// FINISH[for MongoDB Realm.io]
android {
namespace 'com.example.ig'
compileSdk 33
defaultConfig {
applicationId "com.example.ig"
minSdk 28
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
I added the buildscript block as Jay said