前提・実現したいこと
Android Studio(kotlin)でアプリのデータベースの使い方を勉強しようと思い、
realmというものを知ったので、導入しようと思った矢先・・・。
「参考にしているサイトや記事が、どれもちょっとずつ古い」ため、
ずっと何かしらエラーメッセージ的なものが出ているので困っています。
現時点での正しい書き方を知りたいです。
現時点で一番参考になったのはこちらの記事です。
https://teratail.com/questions/340534
(↑ただ質問者も「なぜか解決した」感じで根本的なところを把握していたかどうかは微妙な様子)
発生している問題・エラーメッセージ
jcenter maven repository is no longer receiving updates:newer library versions may be available elsewehre
該当のソースコード
▼build.gradel(:app)
kotlin
plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'realm-android' android { compileSdk 31 defaultConfig { applicationId "com.example.samplerealm" minSdk 21 targetSdk 31 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 } kotlinOptions { jvmTarget = '1.8' } } dependencies { implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'com.google.android.material:material:1.5.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' }
▼build.gradle(project:)
kotlin
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath "io.realm:realm-gradle-plugin:10.8.0" } } plugins { id 'com.android.application' version '7.1.2' apply false id 'com.android.library' version '7.1.2' apply false id 'org.jetbrains.kotlin.android' version '1.6.10' apply false } task clean(type: Delete) { delete rootProject.buildDir }
試したこと
色んなサイトを参考にしながら、ようやくここまでたどり着いた、という所で、
またしてもWarning・・・ということで、力尽きました。
●結局、今のところは合っているのか(jcenterの記述だけが違う)
●そもそも、今までのところが全部違うから何をやってもエラーなのか
自分では判断がつきません。
Realmの記述は、日に日に変化するようで、どのサイトも「ちょっとずつみなさん違う」というのも
素人には混乱の原因のようでして・・・。
現時点での正しい書き方をご教授願いたい
補足情報(FW/ツールのバージョンなど)
Android Studio Bumblebee
まだ回答がついていません
会員登録して回答してみよう