英文:
Android Studio Flamingo android lifecycle issue with Android Devices, after adding Google Maps plugin
问题
I understand that you're experiencing issues with building a cross-platform connected device Google Maps-enabled app using the Flutter framework on Android Studio Flamingo 2022.2.1 Patch 2. It seems that you are facing problems related to the google_maps_flutter
and flutter_plugin_android_lifecycle
dependencies. Additionally, there may be some issues related to your system PATH.
Here are the relevant parts of your message:
- flutter run works seamlessly until the
google_maps_flutter: ^2.4.0
dependency is used underpubspec.yaml
. - After adding
flutter_plugin_android_lifecycle: ^2.0.15
, the problem still persists. - iOS build is okay, and Android was perfect before adding Google Maps.
- You have a strange issue with your system PATH, as reported by
flutter doctor
. - You have provided your
pubspec.yaml
dependencies andflutter doctor -v
output. - You've included parts of your
android/build.gradle
file. - You've mentioned trying to resolve the issue based on some online sources, but it hasn't worked.
Please let me know if you need assistance with any specific part of this information or if you have any questions related to resolving the issue.
英文:
Trying to build a cross platform connected device Google Maps enabled App using flutter framework on Android Studio Flaming 2022.2.1 Patch 2, without success. The flutter run works seemlessly until device dependency google_maps_flutter: ^2.4.0 is used under pubspec.yaml.
Also after added this
flutter_plugin_android_lifecycle: ^2.0.15
the problem still here.
iOS build is ok, also Android was perfect before Google Maps was added.
Please note that I have a strage issue, with my system PATH.
Doctor tell me that I have an Issue, but the PATH is perfect and built for iOS is ok.
I will write another post for this strange issue.
Coming back to this question, I searched for solutions over the web, but unsuccessfully, so this is my dev environment, hoping someone can help me.
pubspec.yaml
dependencies:
http: ^0.13.6
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
# Google Area
google_maps_flutter: ^2.4.0
google_fonts: ^4.0.4
flutter_plugin_android_lifecycle: ^2.0.15
flutter doctor -v
[!] Flutter (Channel stable, 3.10.6, on macOS 13.4.1 22F770820d darwin-x64, locale it-IT)
• Flutter version 3.10.6 on channel stable at /Users/maxmac/Development/flutter
! Warning: `flutter` on your path resolves to /Users/MaxMac/Development/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/maxmac/Development/flutter.
Consider adding /Users/maxmac/Development/flutter/bin to the front of your path.
! Warning: `dart` on your path resolves to /Users/MaxMac/Development/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/maxmac/Development/flutter. Consider
adding /Users/maxmac/Development/flutter/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f468f3366c (3 weeks ago), 2023-07-12 15:19:05 -0700
• Engine revision cdbeda788a
• Dart version 3.0.6
• DevTools version 2.23.1
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/maxmac/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] Connected device (4 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 14 (API 34) (emulator)
• iPhone 14 (mobile) • 387BA0EA-FD06-4ABE-82E3-40FAE3AEBEDE • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 13.4.1 22F770820d darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 115.0.5790.170
[✓] Network resources
• All expected network resources are available.
android/build.gradle.
As you can see I have added both
[ mavenCentral() ] and
[ maven { url "https://maven.google.com" } ]
buildscript {
ext.kotlin_version = '1.9.0'
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//implementation 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
This is Adroid Project Structure settings
The following error are generated (only for Android build)
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':flutter_plugin_android_lifecycle'.
> Could not resolve all files for configuration ':flutter_plugin_android_lifecycle:classpath'.
> Could not find com.android.tools.build:gradle:4.3.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.3.1/gradle-4.3.1.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/4.3.1/gradle-4.3.1.pom
Required by:
project :flutter_plugin_android_lifecycle
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':flutter_plugin_android_lifecycle' of type org.gradle.api.Project.
> Could not get unknown property 'android' for project ':flutter_plugin_android_lifecycle' of type org.gradle.api.Project.
Trying to do some additional setting, for example from here maps template issue, and again nothing.
答案1
得分: 1
I have translated the text you provided:
"接近变得真的很疯狂,花了好几天试图重建和更改我的开发环境设置,还在 GitHub 上发布了问题,但没有得到任何答案,我自己找到了问题。
这绝对是插件 flutter_plugin_android_lifecycle-2.0.15
的源代码中的一个错误。
我在它的 build.gradle 中找到了这个错误。
如果你使用的是 MAC OS,你需要前往这个路径:
/Users/<你的用户名>/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.15/android
在 guild.gradle 文件中,有这个错误的依赖项:
classpath 'com.android.tools.build:gradle:4.3.1'
我将其更改为:
classpath 'com.android.tools.build:gradle:7.0.2'
... 重建之后,问题就解决了。
我还会尝试使用
classpath 'com.android.tools.build:gradle:7.2.1'
因为之前版本,在同一个 pub.dev 目录中,flutter_plugin_android_lifecycle-2.0.8
,有这个依赖项。
现在我的 pubspec.yaml
,用于 Google 地图只有这些依赖项:
google_maps_flutter: ^2.4.0
希望这能帮助你。"
英文:
Near to become really crazy, days trying to rebuild and change setup of my dev environment, and also after post the issue on github without any answer, I have found the issue by myself.
This is definitely a bug on source code of the plugin flutter_plugin_android_lifecycle-2.0.15
.
I have found the bug on its source code, in its build.gradle.
You have to go here, for MAC OS:
/Users/<your name>/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.15/android
The guild.gradle, have this wrong dependence
classpath 'com.android.tools.build:gradle:4.3.1'
I have changed it in
classpath 'com.android.tools.build:gradle:7.0.2'
... and after rebuilt, the problem is SOLVED.
I will try also with
classpath 'com.android.tools.build:gradle:7.2.1'
Because the previous release, in the same pub.dev directory, flutter_plugin_android_lifecycle-2.0.8
, has this dependence.
Now my pubspec.yaml
, for Google Maps has got only this dependencies:
google_maps_flutter: ^2.4.0
Hoping this can help you.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论