I developed Fake GPS application
and all my codes work nicely on debug mode.
When i try "mock location" on **release version**
, i got this error;
java.lang.SecurityException: Requires `ACCESS_MOCK_LOCATION` permission
I already had ACCESS_MOCK_LOCATION
in debug/AndroidManifest file.
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
And already "Allow Mock Location" checked in "Delevoper Options".
Finally; i cant add "ACCESS_MOCK_LOCATION"
on main/AndroidManifest.xml
. Android Studio dont approve this permission.
I tried on Samsung Note 3, V: 4.4.2
Whole of the expection;
java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION permission
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at android.location.ILocationManager$Stub$Proxy.addTestProvider(ILocationManager.java:944)
at android.location.LocationManager.addTestProvider(LocationManager.java:1205)
at egebit.getlocation.MapsActivity.mockLocation(MapsActivity.java:201)
at egebit.getlocation.MapsActivity$2.onClick(MapsActivity.java:118)
at android.view.View.performClick(View.java:4652)
at android.view.View$PerformClick.run(View.java:19311)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5692)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
In that case you are just adding for debug, but it's needed on release too.
You could add to Manifest(not debug) file with ignore value
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION"
tools:ignore="MockLocation,ProtectedPermissions" />