2017-05-17 39 views
0

我有Android項目,我想在其中使用kso​​ap2。我無法在我的課堂上導入ksoap2

我將.jar(ksoap2)粘貼到我的文件夾庫中,然後右鍵單擊並繼續「添加爲庫」。

enter image description here

之後我同步我的gradle產出,在文件的build.gradle Android Studio中更新的依賴,就像這樣:

編譯文件( '庫/ ksoap2-機器人組裝-3.6.1.jar' )

最後在我的課MainActiviy.java我想輸入import org.ksoap2.Envelope,IDE不能識別類ksoap2。

mi程序有什麼問題?

此致敬禮。

回答

0

你只需要粘貼的.jar在庫,並在你的build.gradle添加此(APP)

compile fileTree(dir: 'libs', include: ['*.jar']) 

然後同步。

+0

非常感謝。我認爲我的build.gradle是正確的。是: apply plugin:'com.android.application'dependencies {compile fileTree(include:['* .jar'],dir:'libs')androidTestCompile('com.android.support.test.espresso:espresso- core:2.2.2',{exclude group:'com.android.support',module:'support-annotations'})compile'c​​om.android.support:appcompat-v7:23.4.0'compile'c​​om.android。 support.constraint:constraint-layout:1.0.0-alpha9'testCompile'junit:junit:4.12'compile files('libs/ksoap2-android-assembly-3.6.1.jar')} 它不正確? –

0

問題是我直接在文件瀏覽器/查找器中將.jar文件粘貼到庫中。正確的方法是通過Android Studio將.jar粘貼到libs中。

  1. 在文件瀏覽器/查找程序.jar文件中,右鍵單擊並複製。
  2. 在Android Studio中的Project選項卡中選擇「Project」以查看完整的結構。然後你可以看到libs文件夾。在libs文件夾,並繼續
  3. 右鍵單擊「粘貼爲庫」

Android Studio中創建正確的結構。

相關問題