top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to avoid my app being debugged on android emulator ?

+1 vote
494 views

I found that most released apps(including system apps) can be debugged on the emulator by the way following:
1. install the app on the emulator, and launch it
2. run adb shell ps to get the pid of the app
3. run adb jdwp, if you find the pid in the output, then you can attach to the app by running
adb forward tcp:1234 jdwp:$pid_you_find and jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=1234
4. you can use commands such as "classes" to see the classes of the app, even "stop" to set breakpoint and "eval" to run many functions and see the members of the objects.
I have 2 questions:
1. Why these tricks fail on the phones? What's the difference between the rom of emulator and phones?
2. How to avoid my app being debugged through such way?

posted Aug 23, 2013 by Luv Kumar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
answer Aug 25, 2013 by Amit Parthsarthi
+1 vote

1) On Emulators, debug or eng builds you have ro.debuggable = 1, which allows all apps to be debugged. on production builds this is set to 0 so to debug an app you have to set it from the app's manifest.
2) you cant, as you cant stop smb decompiling it. if u r afraid of smb sees what u r app does better obfuscate it.

answer Aug 25, 2013 by Majula Joshi
Similar Questions
+1 vote

I have installed my custom app in Packages/apps/

in the app, I use a simple Videoview for video playbacks (3gp or mp4). it works in actual device/ADT emulator, but If I run it in AOSP emulator, it says "Failed to open file : the path of the video"

// Retrieving file from internal file 
systemVideo.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.test));
+2 votes

I find that the emulator's memory increase rapidly when check GPU on. You can do the reproduction as following:
1. Turn on GPU following http://developer.android.com/tools/devices/emulator.html#acceleration
2. Power on the emulator
3. Launch some apps by mouse, (i,e. launch Settings then Clock, and Settings then Clock ...)
4. Check the memory usage of emulator by top command on Ubuntu and ProcessExplorer on Windows

I found that the apps with property android:hardwareAccelerated="true" is more worse.

+1 vote

How can we debug the Android framework Java code? i know how I can debug the c/c++ code with the help of GDB server etc, but I searched a lot on Google but did not get the solution, currently i am totally relying on Logs but I really need something to Debug the java code inside framework and etc?
please give me some pointers or some details about debugging AOSP framework java code?

+1 vote

Can any one please guide me to debug Android code. I tried to use GDB and GDBServer for this but couldn't succeed.

+1 vote

My app cashes when i click submit, it doesnt verify the fields as it should.
It works the way i want to but if i click on submit without entering anything it crashes.

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button addBtn = (Button) findViewById(R.id.addBtn);
        addBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText amoutGiven = (EditText) findViewById(R.id.amountG);
                EditText manyPeople = (EditText) findViewById(R.id.mPeople);
                EditText moenyGiven = (EditText) findViewById(R.id.moneyG);
                TextView changeTxt  = (TextView) findViewById(R.id.changeTxt);
                Button nxtBtn     = (Button) findViewById(R.id.nxtBtn);
                Button tryBtn     = (Button) findViewById(R.id.tryBtn);
                android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);

                if (amoutGiven.getText().length()==0){
                    amoutGiven.setError("This field is required");
                }

                if (manyPeople.getText().length()==0){
                    manyPeople.setError("This field is required");
                }

                if (moenyGiven.getText().length()==0){
                    moenyGiven.setError("This field is required");
                }

                int num1 = Integer.parseInt(amoutGiven.getText().toString());
                int num2 = Integer.parseInt(manyPeople.getText().toString());
                int num3 = Integer.parseInt(moenyGiven.getText().toString());
                int total = num1 * num2;
                int change = num3 - total;

                changeTxt.setVisibility((changeTxt.getVisibility() == View.VISIBLE)
                        ? View.INVISIBLE : View.VISIBLE);

                if (change < 0 ){
                    changeTxt.setText("Your numbers dont add up");
                    tryBtn.setVisibility((tryBtn.getVisibility() == View.VISIBLE)
                            ? View.INVISIBLE : View.VISIBLE);
                    tryBtn.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            startActivity(new Intent(MainActivity.this, MainActivity.class));

                        }
                    });

                }else {

                    changeTxt.setText( "Give Back Change oF: R" + change +"" );
                    nxtBtn.setVisibility((nxtBtn.getVisibility() == View.VISIBLE)
                            ? View.INVISIBLE : View.VISIBLE);
                    nxtBtn.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            startActivity(new Intent(MainActivity.this, MainActivity.class));    
                        }
                    });    
                }    
            }
        });    
    }
}
...