[英]How to use code from a project in a maven repository
我正在嘗試使用此項目中的代碼: https : //github.com/gabrielemariotti/cardslib ,並且正在嘗試使用intelij進行此操作。 在庫隨附的說明中,它只是簡單地說將其添加到build.gradle文件中:
dependencies {
compile 'com.github.gabrielemariotti.cards:library:1.3.0'
}
但是,當我添加此代碼並嘗試使用intelij項目中的代碼時,會出現諸如無法解析符號之類的錯誤。因此,我想知道使用intelij必須使用此項目代碼的其他步驟。 任何幫助表示贊賞。
我的build.gradle文件當前如下所示:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/GoogleAdMobAds.jar')
compile files('libs/libGoogleAnalyticsV2')
compile files('libs/amazon-ads-5.1.10.jar')
compile project('libraries/cardslib/library')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
dependencies {
// Cards Library
compile 'com.github.gabrielemariotti.cards:library:0.6.0'
compile project(':libraries:cardslib:library')
}
這里的文檔對新的Maven用戶也很有幫助。
請參考下面的鏈接以獲取更多詳細信息...
您需要將Maven中央存儲庫添加到構建文件中。 最簡單的方法是將build.gradle
直接放在apply plugin: 'android'
下的build.gradle
:
repositories {
mavenCentral()
}
完成后,將您的IDE與gradle文件重新同步。
它應該像其他任何Maven中央依賴項(例如ABS)一樣解決依賴項。
如果您使用rootProject / libraries / cardslib中的源(克隆了git repo),則將其庫添加到rootProject / settings.gradle中:
include ':appModule', ':libraries:cardslib:library'
然后在rootProject / appModule / build.gradle中:
dependencies {
compile project(':libraries:cardslib:library')
}
或者 ,如果您使用maven,則只需在rootProject / appModule / build.gradle中執行以下操作:
dependencies {
compile 'com.github.gabrielemariotti.cards:library:1.3.0'
}
因此該庫的jar / aar將在〜/ .gradle / caches / modules-2 / ...中下載並進行編譯。
從上面選擇一個,不要同時做。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.