gpt4 book ai didi

Flutter Build 失败,Geolocation 插件出现异常

转载 作者:IT王子 更新时间:2023-10-29 07:10:11 25 4
gpt4 key购买 nike

每当我尝试包含 flutter geolocation( https://github.com/loup-v/geolocation ) 插件时,我都会遇到以下错误。

Initializing gradle...
Resolving dependencies...
Running 'gradlew assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
Finished with error: Gradle build failed: 1

我的 pubspec.yml 依赖列表是

dependencies:
flutter:
sdk: flutter
google_sign_in: "^3.0.2"
firebase_auth: "^0.5.5"
shared_preferences: "^0.4.1"
cloud_firestore: "^0.7.2"
firebase_storage: "^0.2.5"
image_picker: "^0.4.1"
progress_hud: "^0.2.2"
cached_network_image: "^0.4.1"
intl: "^0.15.6"
path: "^1.5.1"
geolocation: "^0.2.1"

我的app>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.")
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 27

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.bhramaan.bhramaan"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
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.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

apply plugin: 'com.google.gms.google-services'

出了什么问题?

最佳答案

我可以建议三件事来提供帮助。第一种是通过首先运行 flutter clean 然后再次运行来进行完全重建。有时候,flutter 和 android 之间的事情会有点困惑,这会有所帮助。

接下来我要做的是检查您获得的所有 Play 服务的版本是否相同。出于某种原因,gradlew 有时会搞砸。从 android 运行 gradlew app:dependencies(如果您使用的是 mac/linux,则运行 ./gradlew)。如果您获得不同的版本,请将它们全部添加为同一版本的依赖项。

例如,在我的android/app/build.gradle中,我必须设置

implementation 'com.google.android.gms:play-services-base:15.0.2'
implementation 'com.google.android.gms:play-services-vision:15.0.2'

尽管 Gradle 应该已经解决了这个问题。特别要注意 com.google.android.gms:play-services-location,因为它是地理定位包的依赖项。 com.android.support 库也是如此。

如果仍然不起作用,请尝试直接运行 gradle 构建,特别是查看堆栈跟踪(gradlew app:build --stacktrace 来自 android 文件夹),看看它是否告诉您任何信息。然后您可以发布它,或查看通用的 Android 问题以寻求解决方案。可能是您需要启用 multi-dex,尽管我不这么认为。

关于Flutter Build 失败,Geolocation 插件出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50747483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com