android - Mock Location permission issue on release app


Question: 

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)



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

  <uses-permission
    android:name="android.permission.ACCESS_MOCK_LOCATION"
    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 git@github.com:libgit2/libgit2sharp.git 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 vb.net

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