実現したいこと
- Android StudioでRealmというデータベースを使いたい.
前提
サイト( https://www.youtube.com/watch?v=vutHpI4nI3k&t=312s )を参考に,Realmを使って,EditTextに入力されたテキストを保存するシステムを作っています.
Build.gradle(Project)とBuild.gradle(app)に以下のコードを記述し,実行するとエラーが出ます.
発生している問題・エラーメッセージ
- エラー①
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin 'realm-android'.
- エラー②
Caused by: com.android.builder.errors.EvalIssueException: API 'android.registerTransform' is removed.
- エラー③
Caused by: java.lang.RuntimeException: com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
- エラー④
Caused by: com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
該当のソースコード
Build.gradle(Project)
1buildscript { 2 repositories { 3 mavenCentral() 4 } 5 dependencies { 6 classpath "io.realm:realm-gradle-plugin:10.11.1" 7 } 8} 9 10 11plugins { 12 id 'com.android.application' version '8.0.0' apply false 13 id 'com.android.library' version '8.0.0' apply false 14 id 'org.jetbrains.kotlin.android' version '1.8.0' apply false 15} 16
Build.gradle(app)
1plugins { 2 id 'com.android.application' 3 id 'org.jetbrains.kotlin.android' 4 id 'org.jetbrains.kotlin.kapt' 5} 6 7 8 9apply plugin: "realm-android" 10 11 12 13android { 14 namespace 'com.app4.myapplication4_databasepractice' 15 compileSdk 33 16 17 defaultConfig { 18 applicationId "com.app4.myapplication4_databasepractice" 19 minSdk 30 20 targetSdk 33 21 versionCode 1 22 versionName "1.0.0" 23 24 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 25 } 26 27 buildTypes { 28 release { 29 minifyEnabled false 30 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 31 } 32 } 33 compileOptions { 34 sourceCompatibility JavaVersion.VERSION_1_8 35 targetCompatibility JavaVersion.VERSION_1_8 36 } 37 kotlinOptions { 38 jvmTarget = '1.8' 39 } 40 41 42} 43 44dependencies { 45 46 implementation 'androidx.core:core-ktx:1.10.0' 47 implementation 'androidx.appcompat:appcompat:1.6.1' 48 implementation 'com.google.android.material:material:1.8.0' 49 implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 50 testImplementation 'junit:junit:4.13.2' 51 androidTestImplementation 'androidx.test.ext:junit:1.1.5' 52 androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' 53} 54
補足情報(FW/ツールのバージョンなど)
- 開発環境:Android Studio Flamingo
- 言語:Kotlin
- SDK:javaSD
あなたの回答
tips
プレビュー