I'm trying to make kSOAP working in my Android project with Gradle.
This is my project's build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
maven {
url 'http://ksoap2-android.googlecode.com/svn/m2-repo'
}
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'ch.acra:acra:4.5.0'
compile 'com.google.guava:guava:12.0'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.0.0'
}
The library seems to be included in the project and compilation DOES work but when I try to import a class (ie SoapObject) it seems like the namespace does not even exist. The funny thing is that the other libraries (such as ACRA or Guava) are working fine. How can I solve this problem?
This took me a bit to figure out as well, but I have finally gotten it working. I've been working on a WSDL parser that parses for KSoap and finally got that working only to fight through Gradle with the import of ksoap. At anyrate here is how you do it.
apply plugin: 'android-library'
buildscript {
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.google.code.ksoap2-android:ksoap2-android:3.1.1'
}
}
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
compile 'com.google.code.ksoap2-android:ksoap2-android:3.1.1'
}
Of course mine is a service library, so you may want to use apply plugin: 'android'.
Hopefully this helps and saves somebody some time.
I am using @amitav13's solution but the URL of the repository has changed:
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
}
Current version as of now is 3.6.0
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.0'
This did work for me.
Here's a more minimal version of the build.gradle suggested by Sam that works for me:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.2'
}
Note that this is the app's build.gradle, I have not made any modifications to the project build.gradle.
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
and inside Dependencies
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.1'
I was in the same situation. And I gave up to add that jar from mavencentral.
I added the raw jar as a lib.
- Download the latest (or whatever version) of ksoap2-android from
this url
- Call it in the build.gradle, see below
Here is the code:
dependencies {
compile files('libs/ksoap2-android.jar')
}
I hope it will help.
More simple solution is just download the .jar from http://www.bvbcode.com/code/ed5zc936-1814251-down and add this .jar file to your libs folder.
Finally in your build.gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
}
This worked fine for me.