簡體   English   中英

如何在gradle中添加項目級別的依賴項

[英]how to add a project level dependency in gradle

我的應用程序中有一個應用程序和一個android庫,在開發環境中,我想提供一個項目級別的依賴項,即(Project:XXX)build.gradle文件中的依賴項。 這是我的項目級別build.gradle的外觀(局部視圖)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

        compile 'io.reactivex:rxandroid:1.1.0'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
        compile 'io.reactivex:rxjava:1.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

我收到Gradle DSL method not found : compile()的錯誤Gradle DSL method not found : compile()

android中有沒有一種方法可以提供常見的項目級別依賴關系。

除了buildscript塊中的classpath ,您不能將依賴項添加到任何其他范圍。 這是您聲明項目依賴關系的方法(在另一個項目中,而不是buildscript ):

dependencies {
        compile project(':shared')
    }

您正在使用buildscriptdependencies塊。 這是錯誤的。

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}



dependencies {
     compile 'io.reactivex:rxandroid:1.1.0'
     compile 'io.reactivex:rxjava:1.1.0'        
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM