アプリをRunで起動すると、下記のようなエラーが出ます。
●エラー内容
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Finished with error: Please review your Gradle project setup in the android/ folder.
- Error running Gradle:
ProcessException: Process "C:\Users<UserName>\AndroidStudioProjects\flutter_app2\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
- Where:
Build file 'C:\Users<UserName>\AndroidStudioProjects\flutter_app2\android\build.gradle' > line: 24
- What went wrong:
A problem occurred evaluating root project 'android'.
A problem occurred configuring project ':app'.
Could not resolve all artifacts for configuration ':app:classpath'.> Cannot resolve external dependency com.google.gms:google-services:4.0.1 because no repositories are defined. Required by: project :app
- 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.
- Get more help at https://help.gradle.org
BUILD FAILED in 1s
Command: C:\Users<UserName>\AndroidStudioProjects\flutter_app2\android\gradlew.bat app:properties
build.gradleファイル内に、下記の内容を記載しない場合はエラーは発生しないので、この部分がエラーの原因と思われますが、対応方法などご教授いただけると大変助かります。
buildscript { dependencies { // Add this line classpath 'com.google.gms:google-services:4.0.1' } } allprojects { // ... repositories { google() // Google's Maven repository // ... } } apply plugin: 'com.android.application' android { // ... } dependencies { // ... implementation 'com.google.firebase:firebase-core:16.0.1' // Getting a "Could not find" error? Make sure you have // added the Google maven respository to your root build.gradle } // ADD THIS AT THE BOTTOM apply plugin: 'com.google.gms.google-services'
●build.gradle全文
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion 28 lintOptions { disable 'InvalidPackage' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.androidstudio.flutter_app2" minSdkVersion 16 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } } } flutter { source '../..' } dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } buildscript { dependencies { // Add this line classpath 'com.google.gms:google-services:4.0.1' } } allprojects { // ... repositories { google() // Google's Maven repository // ... } } apply plugin: 'com.android.application' android { // ... } dependencies { // ... implementation 'com.google.firebase:firebase-core:16.0.1' // Getting a "Could not find" error? Make sure you have // added the Google maven respository to your root build.gradle } // ADD THIS AT THE BOTTOM apply plugin: 'com.google.gms.google-services'
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。