2016-11-23 15 views
0

我想爲我的android項目使用「slib-dist-0.9-all-jar」。slib-dist-0.9-all-jar gradle build中無法識別的依賴關係

我從semantics measure library下載了jar,並將其複製到我的android項目/ apps/libs文件夾中。並在gradle中添加一行爲「編譯文件('libs/slib-dist-0.9-all-jar')」,但它表示它不是jar文件。我也試過直接給gradle這個構建與
compile group: 'com.github.sharispe', name: 'slib-sml', version: '0.9.1'但在這種情況下,它說

Unrecognized dependency: 'com.github.sharispe:slib-graph:0.9.1' (type: 'pom', extension: 'pom')

請幫助我能做些什麼來使用它作爲jar文件,而不是pom?

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:23.3.0' 
compile files('libs/slib-dist-0.9-all-jar') //OR THIS 
compile group: 'com.github.sharispe', name: 'slib-sml', version: '0.9.1' 
} 
+0

你把它作爲庫添加了嗎? –

回答

0

最後,大量的研究和試驗後,我發現了一個解決方案, 按照此步驟添加SLIB-DIST-0.9全jar.jar任何外部JAR文件到Android Studio項目: -

  • 步驟1:複製jar文件並將其粘貼到您的項目** Project_Location \應用**目錄。
  • 第2步:轉到Android Studio中 - >然後單擊文件菜單上 - >轉到項目結構 - >轉到依賴標籤 - >點擊 加號按鈕添加新的依賴 - >選擇文件相關 - >然後選擇jar文件slib-dist-0.9-all-jar.jar這是我們在Project_Location /應用/目錄拷貝 - >點擊確定 - > clean and build項目
  • 第3步:依存度將自動在gradle這個文件項目添加。

搖籃依賴將是這樣的: -

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile files('slib-dist-0.9-all-jar.jar') 
} 

截圖如下給出: -

第1步: -複製和粘貼jar文件 enter image description here

步驟2: -增加依賴關係 enter image description here

第3步: -後的gradle乾淨文件,並建立 enter image description here

希望這會幫助你。

+0

我不認爲它將它添加爲庫或導入它作爲jar .. gradle不認爲它是罐子因爲它看起來是pom – Jana

+0

我得到此錯誤:警告:項目應用程序:只支持Jar型本地依賴項。無法處理: – Jana

+0

好的。我認爲它是一個罐子。我很快就會給你一個解決方案。 –

0

如果你使用過Android Studio,請在這裏接受的答案:Android Studio: Add jar as library?

compile group: 'com.github.sharispe', name: 'slib-sml', version: '0.9.1'似乎沒有必要(這是用於像Maven的/ JCenter等外部respositories不需要一個jar文件)。