Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide implementation of methods in jar using android studio IDE

I build a jar using Android studio and when I am using this jar in my demo project, when I open some class from my demo project, I was able to see the implementation of the methods in the class Its Looking like this when I open My SDKClass(In Jar).

public class SDKClass{

    public void paymentRequestedFromCreditDebitCard(int i) {
        Toast.makeText(mContext, "Payment Requested:" + i, 1).show();
    }

    public void paymentCanceledByCustomer() {
        Toast.makeText(mContext, "Payment Cancelled", 1).show();
    }

    public void paymentFailed(int i) {
        Toast.makeText(mContext, "Payment Failed \n error code:" + i, 1).show();
    }
}

I want some thing like this

public class SDKClass{

    public void paymentRequestedFromCreditDebitCard(int i) {
        /* compiled code */
    }

    public void paymentCanceledByCustomer() {
        /* compiled code */
    }

    public void paymentFailed(int i) {
        /* compiled code */
    }
}
like image 790
Spiker Avatar asked Mar 08 '26 13:03

Spiker


1 Answers

You can use an obfuscator. E.g. ProGuard. It will change the names of your class, variables in a way that your code is difficult to be reverse engineered. But you can't hide your implementation completely. Please take a look at the google documentation. https://developer.android.com/studio/build/shrink-code.html

like image 175
shalama Avatar answered Mar 10 '26 03:03

shalama



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!