androidmockingmockoon

How to setup Mockoon for Android emulator?


I'm trying to use mockoon for running a mock API to test an Android app (using Retrofit2) on my macOS.

Using 0.0.0.0:[port] or localhost:[port] as the address doesn't work.

Any idea what I should be doing differently?


Solution

  • Use 10.0.2.2:[port] for the default emulator and 10.0.3.2:[port] for Genymotion

    Edit AndroidManifest.xml to allow usesCleartextTraffic and internet permissions.

    <manifest 
    ....
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    
    <application
        ....
        android:usesCleartextTraffic="true"
        ....
    </application>
    

    P.S. Remember to disable usesCleartextTraffic before deploying app to production!