我有一個Android應用程序項目,其中包含獨立的Android庫模塊,它以二進制格式發佈。我想添加一個能力,在從源代碼構建庫或使用發佈的工件之間切換gradle。 Android應用程序在默認情況下取決於二進制神器:具有庫的Android應用程序的Gradle - DependencySubstitution
compile "com.example.konstantin.mylibrary:mylibrary:${mylibraryVersion}"
現在我想通過源代碼來代替我的二進制神器,所以我加根的build.gradle文件下面的代碼:
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute module("com.example.konstantin.mylibrary:mylibrary:${mylibraryVersion}") with project(':mylibrary')
}
}
但是,當我試圖構建gradle仍然採取二進制神器。這裏有什麼問題?
同樣有趣的是,如果我移動依賴性替代代碼allprojects部分或應用程序模塊的build.gradle文件,比gradle這個構建失敗,以下消息:
Error:Module version MyApplication:app:unspecified, configuration '_debugCompile' declares a dependency on configuration 'default' which is not declared in the module descriptor for MyApplication:mylibrary:unspecified
似乎[此android插件錯誤](https://code.google.com/p/android/issues/detail?id=189483)可能與問題有關 – akd005