google_maps_flutter 与 flutter_facebook_login 不兼容
Posted
技术标签:
【中文标题】google_maps_flutter 与 flutter_facebook_login 不兼容【英文标题】:google_maps_flutter Not compatible with flutter_facebook_login 【发布时间】:2020-10-31 17:13:37 【问题描述】:我在使用“google_maps_flutter”的项目中实施“flutter_facebook_login 包”时遇到了困难。
当我删除 'flutter_facebook_login' 包时,该项目工作正常,但是当我尝试使用此包时,我收到错误并且项目未构建。
'Cannot fit requested classes in a single dex file (# methods: 70285 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.'
当我尝试通过在我的 **Build.gradle 'multiDexEnabled true'* 中设置来解决此问题时。地图停止工作。
我试过这个:Execution-failed-for-task-appmergedexdebug-firestore-flutter 还有这个:Multidex-issue-with-flutter
//Build.gradle implemented MULTIDEXENABLE = TRUE
defaultConfig
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.unMatch"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
错误日志
D8: Cannot fit requested classes in a single dex file (# methods: 70285 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:131)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:118)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102)
at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:444)
at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:335)
at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:50)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:47)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:65)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:61)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:56)
at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:215)
at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:210)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at com.android.tools.r8.utils.t.a(:55)
at com.android.tools.r8.D8.run(:11)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:116)
... 34 more
Caused by: com.android.tools.r8.utils.AbortException: Error: null, Cannot fit requested classes in a single dex file (# methods: 70285 > 65536)
at com.android.tools.r8.utils.Reporter.a(:21)
at com.android.tools.r8.utils.Reporter.a(:7)
at com.android.tools.r8.dex.VirtualFile.a(:33)
at com.android.tools.r8.dex.VirtualFile$h.a(:5)
at com.android.tools.r8.dex.ApplicationWriter.a(:13)
at com.android.tools.r8.dex.ApplicationWriter.write(:35)
at com.android.tools.r8.D8.d(:44)
at com.android.tools.r8.D8.b(:1)
at com.android.tools.r8.utils.t.a(:23)
... 36 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
at com.android.tools.r8.utils.t.a(:55)
at com.android.tools.r8.D8.run(:11)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:116)
... 34 more
Caused by: com.android.tools.r8.utils.AbortException: Error: null, Cannot fit requested classes in a single dex file (# methods: 70285 > 65536)
at com.android.tools.r8.utils.Reporter.a(:21)
at com.android.tools.r8.utils.Reporter.a(:7)
at com.android.tools.r8.dex.VirtualFile.a(:33)
at com.android.tools.r8.dex.VirtualFile$h.a(:5)
at com.android.tools.r8.dex.ApplicationWriter.a(:13)
at com.android.tools.r8.dex.ApplicationWriter.write(:35)
at com.android.tools.r8.D8.d(:44)
at com.android.tools.r8.D8.b(:1)
at com.android.tools.r8.utils.t.a(:23)
... 36 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
* 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
更新 我试过了: 尝试获取位置时出现此错误
MissingPluginException(No implementation found for method requestPermissions on channel flutter.baseflow.com/permissions/methods
将 minSdkVersion 16 更改为 21。
defaultConfig
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.unMatch"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
我尝试更改 LocationPermission 插件。
【问题讨论】:
【参考方案1】:对于此类错误,深入了解 Github 问题可能会更有用。从我所见,将minSdkVersion
设置为21
已经解决了人们没有设置multiDexEnabled true
的问题。其他人则需要完成这两项更改。不管怎样,你的minSdkVersion
太低了。
Issue Reference
【讨论】:
不起作用 :c 我也试过了:换成其他 LocationPermission 插件。验证 AndroidX 兼容。尝试覆盖 MainActivity.kt OnCreate。没有工作。 当我尝试 getLocation MissingPluginException 时出现此错误(未找到通道 flutter.baseflow.com/permissions/methods 上的方法 requestPermissions 的实现 请分享您的pubspec.yaml
并分享以下2个文件:/android/app/src/main/res/values/strings.xml
& /android/app/src/main/AndroidManifest.xml
。
我注意到我在尝试解决错误的过程中删除了 strings.xml
和 facebook 值的实现 AndroidManifest.xml
。在我阅读了您的评论后,我重新实现了它,现在它起作用了..我是个笨蛋哈哈。所以,minSdkVersion
到 21
就是答案。非常感谢您的关注。你帮了我很多
以上是关于google_maps_flutter 与 flutter_facebook_login 不兼容的主要内容,如果未能解决你的问题,请参考以下文章
从 google_maps_flutter 中删除多余的标记和圆圈
谷歌地图使用 google_maps_flutter 插件显示空白地图
Flutter - 如何删除单个 google_maps_flutter ^0.5.21 标记?
Flutter:如何在 google_maps_flutter 中为标记图标设置动画?