Henrique1509 / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

ksoap2 not compatible with ProGuard #105

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create Android software with ksoap2-android 2.6.1
2. Enable obfuscation in the project (i.e. turn on ProGuard) (you will need to 
use the option "-ignorewarnings" to get it to compile)
3. Use XmlPullParserFactory class to extract elements from the SOAP response
4. One class method (either newInstance(), newPullParser() or getEventType()) 
will cause an XmlPullParserException.

What is the expected output?
No exception

What do you see instead?
XmlPullParserException

What version of the product are you using? On what operating system?
ksoap2-android 2.6.1; Android OS 2.3.3

Please provide any additional information below.
The problem does not happen if the program is compiled without ProGuard.
The warnings/errors displayed when "-ignorewarnings" is off should be 
sufficient info for fixing the problem.
I did not get any more fine-grained in figuring out which XmlPullParserFactory 
method raised the exception (they are all currently in the same try block in my 
code), but that shouldn't be material to the errors.

Original issue reported on code.google.com by cgtyo...@gmail.com on 8 Feb 2012 at 6:27

GoogleCodeExporter commented 9 years ago
You need to fix your proguard configuration. This whole problem is not really 
related to ksoap2-android but rather a a proguard item. On the ksoap2-android 
project we could post your proguard.cfg  you got it working. That might be a 
good contribution

Original comment by mosa...@gmail.com on 9 Feb 2012 at 5:13

GoogleCodeExporter commented 9 years ago
It sounds like you've dealt with this before - following is my ProGuard config. 
 Can you point out what's wrong?

-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontpreverify
-verbose

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembers,allowshrinking class * {
    native <methods>;
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context,android.util.AttributeSet);
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context,android.util.AttributeSet,int);
}
-keepclassmembers class * extends android.app.Activity {
    public void *(android.view.View);
}
-keepclassmembers enum  * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keep class * extends android.os.Parcelable {
    public static final android.os.Parcelable$Creator *;
}

Original comment by cgtyo...@gmail.com on 9 Feb 2012 at 1:51

GoogleCodeExporter commented 9 years ago
Get rid of optimizations. Even the new SDK (r17) will have it disabled.. 

use --dontoptimize 

Original comment by mosa...@gmail.com on 9 Feb 2012 at 4:42

GoogleCodeExporter commented 9 years ago
Even after using -dontoptimize (along with -ignorewarnings), I still get the 
same XmlPullParserException.

Original comment by cgtyo...@gmail.com on 9 Feb 2012 at 5:00

GoogleCodeExporter commented 9 years ago
Try a keep for all the classes that bomb. E.g. start with a wide sweep and then 
narrow things down.

Original comment by mosa...@gmail.com on 9 Feb 2012 at 5:46

GoogleCodeExporter commented 9 years ago
I have ksoap working with proguard just fine so this is definitely a 
configuration error.

Original comment by mosa...@gmail.com on 27 Feb 2012 at 5:08

GoogleCodeExporter commented 9 years ago
Could you post your (working) proguard config file, so I can see what I'm doing 
wrong here?

Original comment by cgtyo...@gmail.com on 27 Feb 2012 at 6:37

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Did you get it resolved? I run into the same issue as you. Thanks!

Original comment by whuang1...@gmail.com on 21 Mar 2012 at 5:16

GoogleCodeExporter commented 9 years ago
This works for me ... not very aggressive but it works.. 

Original comment by mosa...@gmail.com on 21 Mar 2012 at 5:32

Attachments:

GoogleCodeExporter commented 9 years ago
I got it resolved by adding the following lines into proguard.cfg:

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

Cheers! ^_^

Original comment by whuang1...@gmail.com on 21 Mar 2012 at 5:51

GoogleCodeExporter commented 9 years ago
I delete org.xmlpull folder in the ksoap....jar,and now it got resolved

Original comment by jsspeedc...@gmail.com on 14 Sep 2012 at 3:50

GoogleCodeExporter commented 9 years ago
 I am using android 2.3.3 os and ksoap2-android-2.5.2.jar.But Converting to signed version apk using eclipse using proguard.cfg.Ksoap2-android-2.5.2.jar is not supported to my project.i calling a asmx webservie to my project.please help me.But without configuring proguard to my project which works finely without any error.I have attached the proguard.cfg file with this request

Original comment by vvrafee...@gmail.com on 22 Aug 2013 at 7:27

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thank @whuang1 so much, It took me hours to find out the reason why my project 
could not be built with proguard and with only 5 line of config rules. It 
finally run success.

Original comment by Tuannguy...@gmail.com on 5 Dec 2014 at 2:09