Настройка gradle модуля библиотеки Android в соответствии с проектом Android, в котором он находится (приложение) - PullRequest
0 голосов
/ 08 июля 2020

У меня есть модуль библиотеки android, который я включил в приложение Android, и я получаю следующую ошибку: я почти уверен, что это связано с несоответствием Gradles между приложением gradle и библиотекой gradle .

Ошибка

Unable to resolve dependency for ':app@stagingDebugAndroidTest/compileClasspath': Could not resolve project :offlineservicelibrary.

Может ли кто-нибудь предложить, какие изменения мне нужно сделать в библиотеке gradle для работы с приложением, пожалуйста

build.gradle(app)
    android {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }

    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    // Should only be temporary to fix CI build issues where version 20.0.5594570 cannot be found,
    // and we should be able to remove the ndkVersion at some point in the future when Gradle will
    // automatically download the NDK version it needs.
    // This seems to have been introduced as a problem somewhere within Gradle 5.6.4, as it worked
    // ok on 5.4.1
    // CI (GitHub Actions) error: "No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669"
    ndkVersion "21.0.6113669"

    defaultConfig {
        applicationId "com.xx.xxx"
        minSdkVersion 21
        targetSdkVersion 22
        versionCode computeVersionCode()
        versionName computeVersionNumber()

        // Add version name to filename of generated APKs
        applicationVariants.all { variant ->
            variant.outputs.all { output ->
                if (!outputFileName.startsWith("app-dev-debug")) {
                    def newName = outputFileName
                    newName.replace(".apk", "-${android.defaultConfig.versionName}.apk")
                    outputFileName = new File(newName)
                }
            }
        }

        testApplicationId "com.xx.xxx.test"
        testInstrumentationRunner "com.xx.xxx.test.runner.TestRunner"

        buildConfigField "Boolean", "LOCAL_DEV_MODE_ENABLED", 'false'
        buildConfigField "String", "LOCAL_DEV_PROXY_IP", '""'
        buildConfigField "Integer", "LOCAL_DEV_PROXY_PORT", '0'
        buildConfigField "Boolean", "LOCAL_DEV_PROXY_ENABLED", 'false'
    }

    dexOptions {
        javaMaxHeapSize "1g" // use 1Gb of ram to launch android
    }

    sourceSets {
        String commonTestDir = 'src/commonTest/java'
        test {
            java.srcDir commonTestDir
            assets.srcDirs = ['src/commonTest/assets']
        }
        androidTest {
            java.srcDir commonTestDir
            assets.srcDirs = ['src/commonTest/assets']
        }
    }

    signingConfigs {
        if (keystoreProperties) {
            config {
                keyAlias keystoreProperties['keyAlias'] ?: ""
                keyPassword keystoreProperties['keyPassword'] ?: ""
                storeFile file(keystoreProperties['storeFile']) ?: ""
                storePassword keystoreProperties['storePassword'] ?: ""
            }
        }
    }

    buildTypes {
        debug {
            debuggable true
        }
        debugProxy {
            initWith debug
            buildConfigField "String", "LOCAL_DEV_PROXY_IP", "\"${getIP()}\""
            buildConfigField "Integer", "LOCAL_DEV_PROXY_PORT", '8888'
            buildConfigField "Boolean", "LOCAL_DEV_PROXY_ENABLED", 'true'
        }
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            if (keystoreProperties) signingConfig signingConfigs.config

            firebaseAppDistribution {
                serviceCredentialsFile = rootProject.file("google-credentials.json").path
                groups = "qa" // QA tester group defined in Firebase console
            }
        }
    }

    flavorDimensions "environment"
    productFlavors {
        dev { // local dev environment
            dimension "environment"
            applicationIdSuffix ".dev"
            testApplicationId "com.xx.xxx.dev.test"
            versionName android.defaultConfig.versionName + "-dev"
            buildConfigField "Boolean", "LOCAL_DEV_MODE_ENABLED", 'true'
        }
        dump { // local dev "dump" environment, for debugging with production database dumps
            dimension "environment"
            applicationIdSuffix ".dev"
            testApplicationId "com.xx.xxx.dev.test"
            versionName android.defaultConfig.versionName + "-dev-dump"
            buildConfigField "Boolean", "LOCAL_DEV_MODE_ENABLED", 'true'
        }
        staging {
            dimension "environment"
            applicationIdSuffix ".staging"
            testApplicationId "com.xx.xxx.staging.test"
            versionName android.defaultConfig.versionName + "-staging"
        }
        qa {
            dimension "environment"
            applicationIdSuffix ".qa"
            testApplicationId "com.xx.xxx.qa.test"
            versionName android.defaultConfig.versionName + "-qa"
        }
        production {
            dimension "environment"
        }
    }

    testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
        animationsDisabled true
        unitTests {
            returnDefaultValues = true
            includeAndroidResources = true
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
        exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
    }

    lintOptions {
        disable 'ExpiredTargetSdkVersion','InvalidPackage', 'MissingTranslation'
        baseline file("lint-baseline.xml")
    }
}

build.gradle (offlineservicelibrary)

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    flavorDimensions "default"
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'consumer-rules.pro'
    }

    sourceSets {
        String commonTestDir = 'src/commonTest/java'
        test {
        }
        androidTest {
        }
    }

    buildTypes {
        release {
        }
        debugProxy {
        }
    }

    productFlavors {
        dev {
        }
        dump {
        }
        staging {
        }
        qa {
        }
        production {
        }
    }

}

большое спасибо за ваши предложения

R

...