java 无法将 ksoap2 导入 Android Studio
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29269965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot import ksoap2 to Android Studio
提问by Developer
I just added ksoap2 (actually it is ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar) to app/libs folder. Also I have used the Project Structure window to add ksoap2 to the Dependencies tab.
我刚刚将 ksoap2(实际上是 ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar)添加到 app/libs 文件夹中。我还使用项目结构窗口将 ksoap2 添加到依赖项选项卡。
the Build.Gradle has this section
Build.Gradle 有这个部分
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile files('libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
}
Anyway I cannot import ksoap2 like
无论如何我不能像这样导入 ksoap2
import org.ksoap.*;
Any clue?
有什么线索吗?
回答by thienkhoi tran
At first, You should remove ksoap in Project Structure and do the steps bellow.
I have same problem and here is the way which work for me.
1st: Make folder libs in app/libs.
2nd: Copy ksoap.jar to this folder.
3rd: right click to Jar file and chose add as library.
From now, you can import ksoap2 to your code normally.
You can create an object from ksoap2, the library will be imported automatically.
Ex: type SoapObject tempResponse = null
首先,您应该删除项目结构中的 ksoap 并执行以下步骤。
我有同样的问题,这是对我有用的方法。
第一:在 app/libs 中制作文件夹库。
第二:将 ksoap.jar 复制到此文件夹中。
第三:右键单击 Jar 文件并选择添加为库。
从现在开始,您可以正常将 ksoap2 导入到您的代码中。
您可以从 ksoap2 创建一个对象,该库将自动导入。
例如:类型SoapObject tempResponse = null
import org.ksoap2.SoapObject;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
P/s: You should use ksoap library latest is 3.6.0, should not use 3.4.0 ;)
P/s:你应该使用 ksoap 库最新是 3.6.0,不应该使用 3.4.0 ;)