Gradle中的问题

时间:2019-02-24 16:13:33

标签: flutter

我首先遇到了关于我的minSDk版本的问题,所以我更改为26,所以开始出现很多关于cloud_firestore和video_player版本的问题,因此我降级了版本,并且错误也发生了变化,现在我已经开始出现包错误,例如“ txt.something it's missing”,因此我添加了以下代码: 而且我还将自己的编译标准更改为28

   packagingOptions {
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/notice'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license'
        exclude 'META-INF/license.txt'
    }

现在它给了我这个错误:

FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:preDebugBuild'.
    > Android dependency 'androidx.fragment:fragment' has different version for the compile (1.0.0-rc01) and runtime (1.1.0-alpha04) classpath. You should manually set the same version via DependencyResolution

所以我添加了:在我的gradle中,但是开始给我一个错误的循环,即具有不同版本的不同库

configurations.all {
resolutionStrategy {
    force 'androidx.fragment:fragment:v4:1.1.0-alpha04'
}

}

我还尝试将com.google.gms:google-services设置为3.2.1,添加代码:

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex')) {
                details.useVersion "26.1.0"
            }
        }
    }
}

并添加我的gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

我的app / build.gradle:

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    configurations.all {
        resolutionStrategy {

        }
    }


    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.gacitua.catilholi.goodstart"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    packagingOptions {
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/notice'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license'
        exclude 'META-INF/license.txt'
    }

    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 {
    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.android.support:multidex:1.0.3'

}

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

gradle / build.gradle:

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:3.2.1'
    }
}

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
}

0 个答案:

没有答案