Spiker
Spiker

Reputation: 575

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 */
    }
}

Upvotes: 3

Views: 913

Answers (1)

shalama
shalama

Reputation: 1335

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

Upvotes: 1

Related Questions