質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Realm

RealmとはSQLiteやCore Dataに代わるモバイルデータベースです。iOSとAndroidの両方でサポートされています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

1回答

1697閲覧

Realmを使用したいです。

Android-student

総合スコア5

Realm

RealmとはSQLiteやCore Dataに代わるモバイルデータベースです。iOSとAndroidの両方でサポートされています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2022/01/05 15:06

前提・実現したいこと

Android Studio でRealmを使用したいですがbuild.gradleでエラーとなる。

発生している問題・エラーメッセージ

A problem occurred evaluating root project 'Qrread'.

Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'build.gradle'

  • Try:

Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is:

以降省略

該当のソースコード

build.gradle(プロジェクト)

buildscript { repositories { mavenCentral() google() } dependencies { classpath "com.android.tools.build:gradle:7.0.3" classpath "io.realm:realm-gradle-plugin:10.8.0" } } allprojects { repositories { mavenCentral() google() } } task clean(type: Delete) { delete rootProject.buildDir }

build.gradle(:app)

plugins { id 'com.android.application' id 'realm-android' } android { compileSdk 31 defaultConfig { applicationId "com.example.qrread" minSdk 24 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 } } dependencies { implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.1' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' implementation 'com.journeyapps:zxing-android-embedded:4.1.0' }

試したこと

build.gradle(プロジェクト)を次の通りに変更。

buildscript { repositories { mavenCentral() google() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } jcenter() } dependencies { classpath "com.android.tools.build:gradle:7.0.3" classpath "io.realm:realm-gradle-plugin:10.8.0" } } allprojects { repositories { mavenCentral() google() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }

jcenter()の2ヶ所共に消し線が引かれ

エラーメッセージが下記の通りとなった。
A problem occurred evaluating root project 'Qrread'.

Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'build.gradle'

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

補足情報(FW/ツールのバージョンなど)

・Android Studio:Android Studio Arctic Fox 2020.3.1 Patch 4
・パソコンの機種:LIFEBOOK AH53/U FMVA53UW
・OS のバージョン:Windows 10 Home バージョン 21H1
・CPU :"Core i7 4722HQ(Haswell)"
・GPU :"インテル® HD グラフィックス 4600

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hoshi-takanori

2022/01/05 18:51

最近の Android Studio では、build.gradle (プロジェクト) の allprojects { 〜 } は不要になったはず…。
Android-student

2022/01/06 13:23

allprojects { 〜 } を外したら上手くいきました。 ありがとうございました。
guest

回答1

0

自己解決

build.gradle (プロジェクト) の allprojects { 〜 } の部分を削除する。
ありがとうございました。

投稿2022/01/06 13:24

Android-student

総合スコア5

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問