J'essaie d'exécuter une application Flutter que j'écris sur mon appareil, mais lorsque j'essaie de l'exécuter, je ne dépasse jamais l'étape "assembleDebug" et je reçois ce message dans le terminal:
Launching lib\main.Dart on SM N950U in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'Android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.Android.tools.build:gradle:5.6.2.
Searched in the following locations:
- https://dl.google.com/dl/Android/maven2/com/Android/tools/build/gradle/5.6.2/gradle-5.6.2.pom
- https://dl.google.com/dl/Android/maven2/com/Android/tools/build/gradle/5.6.2/gradle-5.6.2.jar
- https://jcenter.bintray.com/com/Android/tools/build/gradle/5.6.2/gradle-5.6.2.pom
- https://jcenter.bintray.com/com/Android/tools/build/gradle/5.6.2/gradle-5.6.2.jar
Required by:
project :
* 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 14s
Finished with error: Gradle task assembleDebug failed with exit code 1
J'ai récemment mis à jour vers gradle 6.0.1 (je suppose que je l'ai fait correctement mais je suis très nouveau dans tout cela) et il n'y a aucun problème avec flutter doctor.
Voici mon build.gradle au niveau du projet:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.Android.tools.build:gradle:5.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Voici le niveau d'application 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 plugin: 'kotlin-Android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
Android {
compileSdkVersion 28
sourceSets {
main.Java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.Android.com/studio/build/application-id.html).
applicationId "com.example.skypeclone1"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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'
}
apply plugin: 'com.google.gms.google-services'
Voici mes propriétés de wrapper Gradle au cas où elles seraient également importantes.
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.Zip
gradle.properties
org.gradle.jvmargs=-Xmx1536M
Android.useAndroidX=true
Android.enableJetifier=true
Android.enableR8=true
Parfois, vous devez exécuter la mise à niveau de Flutter Pub.
J'ai eu un problème de connexion avec VPN (Home Office) mais une fois que je déconnecte VPN, il fonctionne. Donc, il y avait un problème de réseau.