2017-05-17 41 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中创建正确的结构。

相关问题