Reputation: 13
I am using Salesforce SOAP API to do a simple login and logout program. I follow the sample code at http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_login.htm.
This code works fine on desktop.
Then, I port it to Android application with the generated jar file (it is sforce-client.jar
) based on my WSDL file and the wsc.jar
.
However, when I run it, I got the following error,
Could not find class 'com.sforce.soap.enterprise.EnterpriseConnection'
referenced from method salesforceAccess.SalesforceAccess.login
Do you have any idea what cause it and how to solve it?
Thank you so much for the help.
Ada
Upvotes: 0
Views: 772
Reputation: 13
Finally, I solved the problem!
The steps are, 1. Build the correct wsc-xxx.jar file from github.com/forcedotcom/wsc (Thank you, Superfell!) 2. Generate the jar file from wsdl using the above wsc-xxx.jar. NOTE: using jdk1.6 to generate the target 1.6 jar. (or whatever match the Android SDK level!!) 3. Import the jars into the Android project.
I was stuck because I was using jdk1.7 to generate the jar file. However, like what this thread (Android emulator crash: "Dx bad class file magic" / ClassNotFoundException on startup?) said, the Android SDK level is 1.6 (I tried to change to 1.7, the project won't be able to compiled). Therefore, the generated jar file from wsdl won't be able to be packaged in!
The eclipse and ADT doesn't give me any warning or error to tell me. I have to build the Android project from command line (see http://randomsamples.info/blog/phil/android-adt-2101-javalangnoclassdeffounderror-rdimen) and noticed the warning,
[dx] trouble processing:
[dx] bad class file magic (cafebabe) or version (0033.0000)
[dx] ...while parsing com/sforce/soap/enterprise/EnterpriseConnection.cla
ss
[dx] ...while processing com/sforce/soap/enterprise/EnterpriseConnection. class
What a process!!
Upvotes: 0
Reputation: 19040
If you followed the default instructions for building your jar from the WSDL, then you need to add both this generated jar, and the wsc.jar that you used to generate the jar to your android libs folder. From the error it sounds like you're missing the wsc.jar that you used to generate your jar from.
Alternatively you can set -Dstandalone-jar=true
as an option when you generate your jar, and then everything will be in that one generated jar.
Upvotes: 0
Reputation: 3578
Did you add the jar file to the 'libs' directory and check the "Order and Export" checkbox under the properties?
Upvotes: 2