Android-仅调试和发布buildType的应用程序如何使用多样式库?

时间:2019-06-18 16:01:56

标签: android gradle android-productflavors

问题

仅具有调试和发布buildTypes的应用程序如何使用多样式库?

详细信息

我有一个包含两个模块的项目:appmymodule

app模块仅具有调试和发布buildTypes就没有味道。这是应用build.gradle

apply plugin: 'com.android.application'
android {
    default {
    ....
    }

    buildTypes {
        debug {
        }
        release {
        }
    }
}

dependencies {

}

mymodule有两种形式:登录和注册,它们共享相同的基本代码。这是mymodule build.gradle

apply plugin: 'com.android.library'
android {
    default {
    ....
    }

    buildTypes {
        debug {
        }
        release {
        }
    }

    flavorDimensions 'version'
    productFlavors {
        login {
        }
        registration {
        }
    }
}

dependencies {

}

mymodule中,将代码分成这样的源集,以便我可以构建 login.aar registration.aar ,但也可以让它们共享src/main/java的基本代码。我还想在mymodule模块中使用app

|-src/main/java/
|-src/login/java
|-src/registration/java

这是settings.gradle

include ':app', ':mymodule'

我尝试过的

我已将依赖项implementation project(':mymodule')添加到应用程序build.gradle中,但收到以下错误:

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :mymodule.
Show Details
Affected Modules: app

0 个答案:

没有答案