skip to Main Content

Due to app security concern I need to restrict a certain app from being able to run on emulator.
How can CN1 android build app be restricted from running on emulators like Android studio and Genymotion emulators?

2

Answers


  1. Chosen as BEST ANSWER

    Since emulators are rooted by default, adding rooted device check at the start() or runApp() functions of the app is also a great solution.

    public void start() {
    
      if (JailbreakDetect.isJailbreakDetectionSupported()) {
    
        if (JailbreakDetect.isJailbroken()) {
            Log.p("Device is rooted, killing the app...");
            Display.getInstance().exitApplication();
    
        } else {
          //proceed
        }
      } else {
          Log.p("Rooted device check unsupported");
          Display.getInstance().exitApplication();
      }
    }
    

    This is working perfectly in online emulators like Appetize.io and Genymotion Cloud


  2. This seemed like something easy to make so I added it in a PR here. It should be available in next weeks update and would work using code like this in your start method:

    if(getProperty("Emulator", "false").equals("true")) {
        throw new RuntimeException("Emulator not supported");
    }
    

    I based this change on this and this update.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search