如何解决Flutter中的“错误运行Gradle:”?

时间:2019-11-19 07:12:28

标签: android flutter

我正在尝试将firebase_messaging添加到项目中,但我得到的错误很少,最后得到了解决,我遇到了这个错误,做了很多事情来解决此问题,例如删除.gradle文件,但是我无法解决这请帮帮我。

Launching lib/main.dart on Android SDK built for x86 in debug mode...
* Error running Gradle:
ProcessException: Process "/Users/harshavardhan/Workspace/myapp/android/gradlew" exited abnormally:
         *********************************************************
WARNING: This version of sqflite will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See "some link" for more information on the problem and how to fix it.
         This warning prints for all Android build failures. The real root cause of the error may be unrelated.
         *********************************************************
  Command: /Users/harshavardhan/Workspace/fleetconnectbeta_flutter/android/gradlew app:properties
Please review your Gradle project setup in the android/ folder.
Exited (sigterm)

PS:我没有选择在VScode中同步Gradle文件

我的Pubspec.yaml

name: fleetconnect
description: A new Flutter project.

dependencies:
  flutter:
    sdk: flutter
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  material_search: ^0.2.7
  map_view: ^0.0.14
  sqflite: ^1.1.7+1
  path_provider: ^0.4.1
  fluttertoast: ^2.1.2
  firebase_messaging: ^5.1.8
  flutter_svg: ^0.13.1
  url_launcher: ^4.0.2
  share: ^0.5.3
  font_awesome_flutter: ^8.4.0
  charts_flutter: ^0.7.0
  circular_check_box: ^0.0.2
  google_maps_flutter: ^0.5.21+11

dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  assets:
  - assets/icon.png
  - assets/Fleet-connect.png
  - assets/dp.png
  - assets/SplashIcon.png
  - assets/success.png
  - assets/Bgp.png
  - assets/signout.png
  - assets/dashboard.svg
  - assets/live.svg
  - assets/notification.svg
  - assets/account.svg
  - assets/call.svg
  - assets/message.svg
  - assets/share.svg
  - assets/send.svg
  - assets/dropDown.svg
  - assets/report.png
  - assets/send.png
  - assets/FC_Maintenance.png
  - assets/bluetoothBattery.jpg
  - assets/Maintenance.svg
  - assets/moving_ios.png
  - assets/parked_ios.png
  - assets/idle_ios.png
  - assets/inactive_ios.png
  - assets/moving_android.png
  - assets/parked_android.png
  - assets/idle_android.png
  - assets/inactive_android.png

  fonts:
    - family: Nunito
      fonts:
      - asset: assets/MavenPro-Medium.ttf

  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - assets/login_background.png
  #  - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.io/custom-fonts/#from-packages

我的应用程序级别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 plugin: 'com.github.triplet.play'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))


android {
    compileSdkVersion 28

    play {
        track = 'alpha'
        serviceAccountEmail = 'xxxx@api-101010101-1010.iam.gserviceaccount.com'
        pk12File = file('api-1001010101-10101-11010011.p12')
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.xxxx.xxx"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 46
        versionName "1.2.8"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release

            minifyEnabled true
            useProguard true

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.android.support:appcompat-v7:27.1.1'
}

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

0 个答案:

没有答案