SOAP calls - No direct method error KXmlParser appears in moe-sdk-1.4.1/sdk/moe-core.dex

I am trying to use ksoap2-android Jar to make a SOAP call to web services (in shared/common library).

I get an error: Pending exception java.lang.NoSuchMethodError: No direct method error(Ljava/lang/String;)V in class Lorg/kxml2/io/KXmlParser; or its super classes (declaration of ‘org.kxml2.io.KXmlParser’ appears in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex). kxml is used in ksoap.

I assumed ksoap was not supported by MOE, so I tried changing to org.apache.xmlbeans.impl.soap. I got errors trying to implement that, and cannot seem to make a soap call on the IOS side.

Is there a way to fix the soap error, or is there another SOAP library I can use that is compatible with MOE?

Thanks!

Did you add all class from ksoap2 & kxml to proguard config?

Thanks for the reply!
No, I had not added classes to proguard.
I am not familiar with proguard, but I created proguard.append.cfg, and put the following lines in it:
-keep class com.google.code.ksoap2.** { ; }
-keep enum com.google.code.ksoap2.
* { *; }

-keep class org.kxml2.io.KXmlParser.** { *; }
-keep enum org.kxml2.io.KXmlParser.** { *; }

Still same issue “Pending exception java.lang.NoSuchMethodError: No direct method error(Ljava/lang/String;)V in class Lorg/kxml2/io/KXmlParser”

Attached is the entire error log:
###########
# ERROR LOG
###########

dex2oat I 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/dex2oat/dex2oat.cc:2220] /Users/david/.moe/moe-sdk-1.4.1/tools/dex2oat --instruction-set=x86 --base=0x40000000 --compiler-backend=Quick --generate-debug-info --image=/Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex2oat/debug-x86/image.art --image-classes=/Users/david/.moe/moe-sdk-1.4.1/tools/preloaded-classes --oat-file=/Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex2oat/debug-x86/application.oat --dex-file=/Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex:/Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar:/Users/david/.moe/moe-sdk-1.4.1/sdk/moe-ios-retro-dex.jar
dex2oat I 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/runtime/parsed_options.cc:449] setting boot class path to /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex:/Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar:/Users/david/.moe/moe-sdk-1.4.1/sdk/moe-ios-retro-dex.jar
dex2oat W 28803 18638714 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.kxml2.io.KXmlParser from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638715 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.kxml2.io.KXmlSerializer from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlSerializer from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638716 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlPullParser from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638714 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlPullParserException from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638715 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlPullParser from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638715 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.kxml2.io.KXmlParser from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638715 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlSerializer from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638715 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.kxml2.io.KXmlSerializer from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638715 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlPullParserException from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/dex/verification_results.cc:61] Method processed more than once: void android.icu.text.NumberFormat.<clinit>()
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/dex/verification_results.cc:61] Method processed more than once: java.lang.String java.lang.AbstractStringBuilder.substring(int)
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/dex/verification_results.cc:61] Method processed more than once: java.lang.String com.android.org.bouncycastle.util.Strings.toLowerCase(java.lang.String)
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/dex/verification_results.cc:61] Method processed more than once: java.lang.String java.lang.IntegralToString.stringOf(char[])
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlPullParser from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.kxml2.io.KXmlParser from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlSerializer from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.kxml2.io.KXmlSerializer from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlPullParserException from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat I 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/runtime/gc/heap.cc:2729] Explicit concurrent mark sweep GC freed 34390(7MB) AllocSpace objects, 0(0B) LOS objects, 33% free, 8MB/12MB, paused 54us total 13.695ms
dex2oat W 28803 18638716 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlPullParser from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638716 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.kxml2.io.KXmlParser from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638716 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlSerializer from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638716 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.kxml2.io.KXmlSerializer from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/driver/compiler_driver.cc:1860] Skipping class org.xmlpull.v1.XmlPullParserException from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex
 3 Zip: EOCD not found, /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex is not zip
 3 Zip: EOCD not found, /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex is not zip
 3 Zip: EOCD not found, /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex is not zip
dex2oat F 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/oat_writer.cc:649]Unexpected failure to resolve a method: void org.kxml2.io.KXmlParser.error(java.lang.String)
dex2oat F 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/oat_writer.cc:655] java.lang.NoSuchMethodError: No direct method error(Ljava/lang/String;)V in class Lorg/kxml2/io/KXmlParser; or its super classes (declaration of 'org.kxml2.io.KXmlParser' appears in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex)
dex2oat F 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/compiler/oat_writer.cc:655] (Throwable with empty stack trace)
dex2oatNATIVE BACKTRACE:
0   dex2oat                             0x0000000001755659 _ZN3art7Runtime5AbortEv + 99
1   dex2oat                             0x0000000001779a99 _ZN3art10LogMessageD2Ev + 649
2   dex2oat                             0x000000000163d0c7 _ZN3art9OatWriter22InitImageMethodVisitor11VisitMethodEmRKNS_21ClassDataItemIteratorE + 1677
3   dex2oat                             0x0000000001638567 _ZN3art9OatWriter15VisitDexMethodsEPNS0_16DexMethodVisitorE + 257
4   dex2oat                             0x0000000001637eb9 _ZN3art9OatWriter19InitOatCodeDexFilesEm + 179
5   dex2oat                             0x0000000001636e93 _ZN3art9OatWriterC2ERKNSt3__16vectorIPKNS_7DexFileENS1_9allocatorIS5_EEEEjmiPKNS_14CompilerDriverEPNS_11ImageWriterEPNS_12TimingLoggerEPNS_7SafeMapINS1_12basic_stringIcNS1_11char_traitsIcEENS6_IcEEEESN_NS1_4lessISN_EENS_17TrackingAllocatorINS1_4pairIKSN_SN_EELNS_12AllocatorTagE7EEEEE + 611
6   dex2oat                             0x00000000014bda0e _ZN3art7Dex2Oat13CreateOatFileEv + 428
7   dex2oat                             0x00000000014af6a3 main + 611
8   libdyld.dylib                       0x00007fff5d88b115 start + 1
9   ???                                 0x0000000000000009 0x0 + 9

 F 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/runtime/runtime.cc:464]Runtime aborting...
Aborting thread:
"main" prio=5 tid=1 Runnable (still starting up)
  | group="" sCount=0 dsCount=0 obj=0x0 self=0x7fa5d7000c00
  | sysTid=18638676 nice=-1 cgrp=default sched=1/31 handle=0x7fff9699f340
  | state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
  | stack=0x7ffeedf56000-0x7ffeedf5e000 stackSize=8MB
  | held mutexes= "abort lock" "mutator lock"(shared held)
  (no managed stack frames)
Pending exception java.lang.NoSuchMethodError: No direct method error(Ljava/lang/String;)V in class Lorg/kxml2/io/KXmlParser; or its super classes (declaration of 'org.kxml2.io.KXmlParser' appears in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex)
(Throwable with empty stack trace)Dumping all threads without appropriate locks held: thread list lock
All threads:
DALVIK THREADS (1):
"main" prio=5 tid=1 Runnable (still starting up)
  | group="" sCount=0 dsCount=0 obj=0x0 self=0x7fa5d7000c00
  | sysTid=18638676 nice=-1 cgrp=default sched=1/31 handle=0x7fff9699f340
  | state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
  | stack=0x7ffeedf56000-0x7ffeedf5e000 stackSize=8MB
  | held mutexes= "abort lock" "mutator lock"(shared held)
  (no managed stack frames)

dex2oat W 28803 18638676 /Users/rolandvigh/public-repo/aosp/art/runtime/barrier.cc:96] Attempted to destroy barrier with non zero count -1

Skipping class org.kxml2.io.KXmlParser from /Users/david/AndroidStudioProjects/iWish/ios/build/moe/main/dex/classes.jar previously found in /Users/david/.moe/moe-sdk-1.4.1/sdk/moe-core.dex

Seems like the kxml2 you used is conflict with the one android runtime contains. Kxml2 is used internally by android (in libcore) and shoud be invisible to normal applications on normal android. But seems MOE somehow exported that.

Thanks again for the reply. This is what I have found:
ksoap2 uses kxml version 2.2.4
Android JDK uses 2.3.0
I can’t figure out what version moe-core uses

This is what I tried:
iOS gradle added actionsAndOutlets section:
moe {
actionsAndOutlets {
excludeLibrary ‘org.kxml2’
}

in repositories section added:
maven { url ‘https://mvnrepository.com/artifact/net.sf.kxml/kxml2’ }

in dependencies section added the following:
implementation (‘com.google.code.ksoap2-android:ksoap2-android:3.6.2’, {
exclude group: ‘net.sourceforge.kxml’
})

implementation 'net.sf.kxml:kxml2:2.3.0'

I am still not having any luck, same errors.

Interesting thing is on normal android if you try to use class org.kxml2.io.KXmlParser, you will also get this class from libcore instead of your onw version from gradle… I have no idea why google did this.

image
The BootClassLoader means this class is loaded from libcore instead of your own apk.

Hmm, that does seem strange, but the Android part actually works in that I am able to compile and make SOAP calls to my server.

I am still confused by the messages. They seem to contradict themselves.

From what I have seen on the internet, the No such method error is usually caused by different versions of the class /jar. I have tried many different things,

  • attempt to exclude MOE kxml version

  • attempt to load ksoap, excluding kxml.
    – also attempted to load kxml both 2.2.2 and 2.3.0 prior to ksoap.

  • tried adding the following to proguard.append.cfg:
    -dontwarn org.kobjects.**
    -dontwarn org.ksoap2.**
    -dontwarn org.kxml2.**
    -dontwarn org.xmlpull.v1.**

    -keep class org.kobjects.** { ; }
    -keep class org.ksoap2.
    * { ; }
    -keep class org.kxml2.
    * { ; }
    -keep class org.xmlpull.
    * { *; }

    -dontusemixedcaseclassnames
    -dontskipnonpubliclibraryclasses
    -dontoptimize
    -dontpreverify

Lastly, I tried downloading ksoap2, recompiling it with kxml 2.3.0, and copying Jars to a Libs folder (I tried with and without dependencies). I got errors (Error:(5, 21) Gradle: error: package org.kxml2.kdom does not exist) so I added implementation ‘net.sourceforge.kxml:kxml:2.2.0’ and now get Caused by: java.io.IOException: Duplicate zip entry [xmlpull-1.1.3.1.jar:org/xmlpull/v1/XmlPullParser.class]

i also tried ‘net.sourceforge.kxml:kxml:2.3.0’ and get Unexpected failure to resolve a method: void org.kxml2.io.KXmlParser.error(java.lang.String)

Is there anything I can do to get past this issue?

One possible solution is adding the following code to your ios project’s build.gradle:

moeMainProGuard {
    doLast {
        def jar = getOutJar()
        def outputDir = file(jar.getAbsolutePath() + "_")
        copy{
            from(zipTree(jar)){
                exclude "org/kxml2/io/*"
                exclude "org/xmlpull/v1/**/*"
            }
            into outputDir
        }
        delete jar
        ant.jar(update: "true", index: "true", destfile: jar.getAbsolutePath()) {
            fileset(dir: outputDir)
        }
        delete outputDir
    }
}

It’s basically removing those duplicated classes from compiled outputs before it get merged with MOE runtime.

You don’t need to exclude anything from your dependencies with above hack. Keep in mind this is only a HACK so your project could compile and (possibly) run since those classes are not used on android anyway.

1 Like

One possible solution is adding the following code to your ios project’s build.gradle:

moeMainProGuard {
doLast {
def jar = getOutJar()
def outputDir = file(jar.getAbsolutePath() + “_”)
copy{
from(zipTree(jar)){
exclude “org/kxml2/io/"
exclude "org/xmlpull/v1/**/

}
into outputDir
}
delete jar
ant.jar(update: “true”, index: “true”, destfile: jar.getAbsolutePath()) {
fileset(dir: outputDir)
}
delete outputDir
}
}

Thank you so much!! This worked! I am able to get past the compile error and see the SOAP calls.