【问题标题】:gradle is unable to be built in fluttergradle 无法在 flutter 中构建
【发布时间】:2018-09-08 09:56:04
【问题描述】:

在尝试将包添加到我的应用程序 (flutter_html) 后,我收到了 dex 文件错误,我试图实现多 dex,我想我可能已经破坏了一些东西。我目前收到以下错误:

logs from run

这是我的 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 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 "tt.roachwre.extraextra"
        minSdkVersion 21
        targetSdkVersion 28
        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 {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$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'
    implementation 'com.google.firebase:firebase-core:16.0.3'


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

我已经尝试过更新我的 sdks 以及没有什么

【问题讨论】:

  • 我猜你正在查看错误的文件。您发布的是应用程序级别的 build.gradle。在您的 android 文件夹中还有一个 build.gradle 文件。我相信问题出在那儿。

标签: android gradle flutter


【解决方案1】:

你可以尝试添加你的 defaultConfig 这个属性:multiDexEnabled true

像这样:

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "tt.roachwre.extraextra"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
   }

然后运行;

flutter clean

抱歉,我的观点不足以使用评论部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-31
    • 2013-05-11
    • 1970-01-01
    • 2020-11-12
    • 2021-09-16
    • 2018-09-25
    • 2020-01-27
    相关资源
    最近更新 更多