Obfuscating Android app with CORBA
Asked Answered
C

1

1

It so fell out that I use jacorb.jar and CORBA interfaces in my android app. And when I try obfuscate code using Proguard I get a lot of warnings like this one:

    [proguard] Warning: org.jacorb.orb.standardInterceptors.SASComponentInterceptor: can't find referenced
class org.ietf.jgss.Oid

And as the result:

 [proguard] Warning: there were 1223 unresolved references to classes or interfaces.
 [proguard]          You may need to specify additional library jars (using '-libraryjars'),
 [proguard]          or perhaps the '-dontskipnonpubliclibraryclasses' option.
 [proguard] Warning: there were 33 unresolved references to program class member
s.
 [proguard]          Your input classes appear to be inconsistent.
 [proguard]          You may need to recompile them and try again.
 [proguard]          Alternatively, you may have to specify the options
 [proguard]          '-dontskipnonpubliclibraryclasses' and/or
 [proguard]          '-dontskipnonpubliclibraryclassmembers'.

My proguard.cfg :

-injars      bin/classes
-outjars     bin/classes-processed.jar
-libraryjars C:/android-sdk-windows/platforms/android-7/android.jar
-libraryjars libs

-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontnote

-keep class com.android.vending.billing.**

-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.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * implements android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

How to correct these warnings and build working apk file?

Cantillate answered 25/3, 2011 at 13:14 Comment(0)
J
2

Cfr. ProGuard manual > Troubleshooting > Warning: can't find superclass or interface.

Jacorb appears to depend on JGSS, which is not part of the Android runtime. In theory, JGSS should be specified as a library package. However, since your app already runs fine without JGSS, it's fair to assume that this part of the code is never used. You can then switch off the warnings:

-dontwarn org.ietf.jgss.**

ProGuard will no longer complain about these missing classes and proceed with processing the code. The summary in your console output suggests that there are many classes that are probably similar.

Jannajannel answered 25/3, 2011 at 21:59 Comment(4)
I added -dontwarn option for all classes that I don't actually use in my app. But another sort of warnings is still there: [proguard] Warning: org.jacorb.imr.util.AddServerWindow: can't find referenced method 'void pack()' in class org.jacorb.imr.util.AddServerWindow These classes are kept in libs/jacorb.jar. I use -keepclasseswithmembers class org.jacorb.** but it makes no effect.Cantillate
Cfr. ProGuard manual > Troubleshooting > Warning: can't find referenced field/method. Did you try -dontskipnonpubliclibraryclasses (in older version of ProGuard) and maybe -dontskipnonpubliclibraryclassmembers?Jannajannel
I tried to use this options both separately and together (I wrote about it in a question). If I just ignore these warnings (with -ignorewarnings -dontshrink -dontoptimize options) apps services could'n start.Cantillate
Thank you, Eric! Problem is solved. These warnings were unimportant. I used -ignorewarnings and -keep option for all classes that use corba interfaces. And obfuscated application works fine.Cantillate

© 2022 - 2024 — McMap. All rights reserved.