android - Mock Location permission issue on release app


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(
  at android.os.Parcel.readException(
  at android.location.ILocationManager$Stub$Proxy.addTestProvider(
  at android.location.LocationManager.addTestProvider(
  at egebit.getlocation.MapsActivity.mockLocation(
  at egebit.getlocation.MapsActivity$2.onClick(
  at android.view.View.performClick(
  at android.view.View$
  at android.os.Handler.handleCallback(
  at android.os.Handler.dispatchMessage(
  at android.os.Looper.loop(
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(
  at dalvik.system.NativeStart.main(Native Method)

1 Answer: 

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

    tools:ignore="MockLocation" />

More Articles

parsing - Parse JQ output through external bash function?

I want to parse out data out of a log file which consist of JSON sting and I wonder if there's a way for me to use a bash function to perform any custom parsing instead of overloading jq command.Command:tail errors.log --follow | jq --raw-output '. | [.server_name, .server_port, .request_file] | @ts

php - Laravel openssl_private_encrypt(): key param is not a valid private key

I am trying to connect to Chef API with Laravel using PHP-Chef. I have tried to set up my chef config with the data that I got from knife.rb in .chef folder. I have setup client and a key according to the instructions from Knife.rb. But I get:openssl_private_encrypt(): key param is not a valid priva

android - Mock location not working on Google map

I have used code from this. I have changed it a bit. Below is my code snippet. The problem is Google Map is not showing proper location which i have mocked.public class MockGpsProviderActivity extends Activity implements LocationListener {public static final String LOG_TAG = "MockGpsProviderActivity

git - How to use libgit2sharp with ssh-transport-protocol?

When I use libgit2sharp in project to clone repository with ssh-transport protocol, like It throw an exception, says "This transport isn't implemented. Sorry"How can I clone repository with ssh-transport-protocol by using libgit2sharp ?

C# HMAC SHA-256-128 Calculation result not as expected

I'm trying to create a signature to our bank from a specified key but my results is not the same as the info I got from the bank. Can anyone see what I am doing wrong?Link to bank for reference (text in Swedish)Example data are inside the citationmarks .. :)Filedata: "00000000"Key:

regex - Regular expressions in R: pattern repetitions with {}

I am having trouble with a regular expression in R. The goal is to parse a Markdown/reST/knitr report text file in R to remove my own custom comments. These comments are put in the following form: Some sentence is about something <find a citation to this>.As Markdown uses <> for HTML tags,

cmake - How to build openCV 3.3.0 with GStreamer on Windows

Having Gstreamer 1.22 successfully installed I'm not able to configure the project to build OpenCV. CMake isn't able to find GStreamer on my machine. Any ideas how two address this issue?

sql server - How to add Text at the end of each line

I'm developing a program with VB.NET (2013), which works with a local database (sql server 2008 R2),The program is converting database tables into text files ,so how to add some text after the last field of each row at the end of each line in that text file,Thanks, And sorry for my englishIf mytable

c++11 - C++ problem with understanding of counting char variables

I wrote a program that supposed to print the number of characters that i entered till it hits the '#' character. what i don't understand is, when i input in the console more than one character (say "hello world") the program count all the characters in one iteration. why does it count all the charac

powershell - Table - Count Column

I have a PowerShell script that coverts JSON from an API and creates a table output.How would I TOTAL (add or count) the column 'TotalEndpoints' and display the total number of Enpoints?Here is the creation of the table(Invoke-RestMethod @Params).Sites | Format-Table SiteName,SiteId,TotalEndpoints