前提・実現したいこと
google map api keyの構築について質問です.(Android Studio)
公式ドキュメントの手順2で躓いています.デフォルトにpluginsが記述されていないため,何処に記述して良いのか分かりません.
内容は,アプリレベルの build.gradle ファイルを開き、下のコードを plugins 要素に追加するだけです.
発生しているエラー
そもそも私のbuild.gradleには,buildscript {} や plugins {} が存在しないため,書くべき場所が分かりません.
stackoverflowにも同じような問題が貼られていましたが,解決できませんでした.
only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed
試したこと
とりあえず,
build.gradle内のいろんな場所に,以下を挿入してみましたが上手くいきませんでした.
plugins { id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' }
補足情報(FW/ツールのバージョンなど)
私のbuild.gradleの中身です.
apply plugin: 'com.android.application' plugins { id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' } android { compileSdkVersion 29 buildToolsVersion "29.0.3" defaultConfig { applicationId "com.example.パッケージ名" minSdkVersion 22 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } viewBinding { enabled true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { compile(name: 'SkyWay', ext: 'aar') implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.google.android.gms:play-services-maps:17.0.1' //noinspection GradleCompatible implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:2.0.4' implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.0' implementation "androidx.cardview:cardview:1.0.0" implementation 'com.google.android.material:material:1.4.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.google.android.gms:play-services-location:18.0.0' } repositories { flatDir { dirs 'libs' } }
補足

回答1件
あなたの回答
tips
プレビュー