J'ai essayé de mettre en œuvre toutes les choses requises pour Android, mais bien que l'application fonctionne sur iOS, elle ne fonctionne pas sur Android. Quelqu'un peut-il s'il vous plaît me dire ce qui ne va pas et comment résoudre ce problème.
Plugin project :firebase_core_web not found. Please update settings.gradle.
Plugin project :google_sign_in_web not found. Please update settings.gradle.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find firebase-core:16.0.9:.
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
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 2.2s
Exception: Gradle task assembleDebug failed with exit code 1
J'ai ajouté toutes les dépendances nécessaires dans le pubspec.yaml, car cette application fonctionne déjà sur iOS et je veux juste avoir également Android utilisateurs. Mon fichier pubspec.yaml:
name: example
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
firebase_core: ^0.4.0+9
firebase_analytics: ^5.0.2
firebase_auth: ^0.14.0+5
cloud_firestore: ^0.12.9+5
rflutter_alert: ^1.0.3
modal_progress_hud: ^0.1.3
flutter_auth_buttons: ^0.8.0
google_sign_in: ^4.4.1
dev_dependencies:
flutter_test:
sdk: flutter
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
Voici ma build.gradle dans le répertoire Android:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google() // Google's Maven repository
jcenter()
}
dependencies {
classpath 'com.Android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}
allprojects {
repositories {
google() // Google's Maven repository
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
C'est le nouveau message d'erreur:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.example.list'
* 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
26 actionable tasks: 24 executed, 2 up-to-date
nouveau message d'erreur après la modification des paramètres.
Launching lib/main.Dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
D8: Cannot fit requested classes in a single dex file (# methods: 87571 > 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:132)
at com.Android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.Java:119)
at com.Android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.Java:102)
at com.Android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:445)
at com.Android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:348)
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.O.a(:65)
at com.Android.tools.r8.D8.run(:11)
at
com.Android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.Java:117)
... 34 more
Caused by: com.Android.tools.r8.utils.b: Error: null, Cannot fit requested classes in a single dex file (# methods: 87571 > 65536)
at com.Android.tools.r8.utils.y0.a(:21)
at com.Android.tools.r8.dex.K.a(:56)
at com.Android.tools.r8.dex.K$h.a(:5)
at com.Android.tools.r8.dex.b.b(:15)
at com.Android.tools.r8.dex.b.a(:38)
at com.Android.tools.r8.D8.d(:87)
at com.Android.tools.r8.D8.b(:1)
at com.Android.tools.r8.utils.O.a(:30)
... 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
BUILD FAILED in 7s
[!] The shrinker may have failed to optimize the Java bytecode.
To disable the shrinker, pass the `--no-shrink` flag to this command.
To learn more, see: https://developer.Android.com/studio/build/shrink-code
Exception: Gradle task assembleDebug failed with exit code 1
votre prise en charge multidex pour votre application. changez app/build.gradle ajoutez deux lignes de code et vous êtes en or.
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.Android.com/studio/build/application-id.html).
applicationId "com.example.app"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
//add this to resolve dex error
multiDexEnabled true
}
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 {
//add this to resolve dex error
implementation 'androidx.multidex:multidex:2.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Faire flutter pub cache repair
pour résoudre les problèmes avec vos packages/plugins Flutter dans le répertoire de cache (qui pourraient parfois re-télécharger chaque package dans le cache).
Effacer le ~/.pub-cache
le répertoire fonctionnera également. Dans mon système, ce répertoire situé à C:\Users\BLiyanage\AppData\Roaming\Pub\Cache\hosted
(Cet emplacement peut différer pour vous).
Pour IOS .pub-cache
existe à: Users/someuser/.pub-cache/hosted/pub.dartlang.org
Lire la suite ici pour résoudre des problèmes similaires à celui-ci. Et similaire téléscripteur .
Modifiez settings.gradle comme suit:
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('Android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}