2017-07-10 33 views
1

我目前正在通过所提供的迁移指南我们的项目迁移到新gradle这个插件(3.0.0):本地的Android库模块和com.android.tools.build:gradle:3.0.0

https://developer.android.com/studio/preview/features/new-android-plugin-migration.html

在我们的Android项目中,我们有一个库模块和2个应用程序模块。目前,库模块没有风味,只有调试版本的构建类型,而应用程序有多种风格和构建类型。

我在找的是库模块的buildType必须与应用模块刚好匹配。例如,

如果应用程序模块具有名为debugProguard的buildType,那么库模块还必须具有名为debugProguard的buildType。这意味着,在库模块我最终不得不与任何机构申报buildTypes:

buildTypes { 
     ... 

     debugProguard { 
     } 

     ... 
    } 

(从这里开始: Android Studio 3.0 Error. Migrate dependency configurations for local modules

反正是有避免这种情况?图书馆需要消费应用程序的体系结构的一些知识似乎很奇怪。

我想要做的,理想情况是告诉构建系统使用该库的某个buildType作为应用程序的buildType。例如,对于应用程序中的buildType x,y,z,在库中使用'debug',对于i,j,k使用'release'。

在此先感谢

回答

2

他们刚在Canary 7发布的Android 3.0工作室的解决了这个:

You can now specify an alternative build type the consumer should use from the producer using the android.buildTypeMatching property as shown below. The plugin uses the alternative build type only if a matching build type is not found.

android { 
    … 
    // Let’s say your app configures a ‘staging’ build type and a library module 
    // it depends on does not. You can use the property below to tell the Android plugin 
    // to use a library’s ‘debug’ build type instead. 
    buildTypeMatching ‘staging’, ‘debug’ 
} 
+0

辉煌的东西。谢谢! – MattWilliams89

+0

它为我引发错误,这是我的应用程序和库的构建类型https://gist.github.com/anonymous/1dda4a85d4d3c021a8fc07251901f9f2 – DroidLearner

+0

@DroidLearner什么是错误?如果提出新问题可能会更好 –