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" />
Related
What is the difference between the two Android permission below related to browser Bookmark History?
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/> -->
<uses-permission android:name="android.permission.READ_HISTORY_BOOKMARKS" />
My app works fine with the first one only, and crash with the second.
SDK version:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
Error Log when I use the second permission tag:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.SecurityException: Permission Denial: reading com.android.browser.provider.BrowserProvider2 uri content://browser/bookmarks from pid=5063, uid=10050 requires com.android.browser.permission.READ_HISTORY_BOOKMARKS, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1431)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:385)
at android.content.ContentResolver.query(ContentResolver.java:414)
at android.content.ContentResolver.query(ContentResolver.java:357)
at course.labs.permissionslab.BookmarksActivity.loadBookmarks(BookmarksActivity.java:56)
at course.labs.permissionslab.BookmarksActivity.access$000(BookmarksActivity.java:14)
at course.labs.permissionslab.BookmarksActivity$1.onClick(BookmarksActivity.java:32)
at android.view.View.performClick(View.java:4240)
at android.view.View$PerformClick.run(View.java:17721)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Android version: 4.3.1
Thanks!
This release removes support for global bookmarks. The android.provider.Browser.getAllBookmarks() and android.provider.Browser.saveBookmark() methods are now removed. Likewise, the READ_HISTORY_BOOKMARKS and WRITE_HISTORY_BOOKMARKS permissions are removed. If your app targets Android 6.0 (API level 23) or higher, don't access bookmarks from the global provider or use the bookmark permissions. Instead, your app should store bookmarks data internally.
https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-bookmark-browser
I have a weird crash in Lollipopand below. I get a security Exception when trying to download a file from the server, but in devices running Marshmallow and above the app does not crash. Logcat:
Caused by: java.lang.SecurityException: need WRITE_EXTERNAL_STORAGE permission to use DESTINATION_FILE_URI: uid 10229 does not have android.permission.WRITE_EXTERNAL_STORAGE.
In App's grandle I use
targetSdkVersion 22
Will change after our first push on Google Console to target the latest sdk version, but for now this will remain to 22, so no need for run time permissions.
Furthermore, in App's Manifest we declare app's permission.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Also, the code that uses the DownloadManagerinside an AsynckTask :
try {
String dirPath = String.format("%5$s/%1$s/Resources/%2$s/%3$s/%4$s/", userID, resource.getiD(), filePackage.getiD(), language, dir.getCanonicalPath());
File makeDirs = new File(dirPath);
makeDirs.mkdirs();
} catch (Exception ex) {
ex.printStackTrace();
}
this.downloadManager = (DownloadManager) getApplicationContext().getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(url);
request.setDestinationInExternalFilesDir(getApplicationContext(), null, filePath);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
request.setVisibleInDownloadsUi(false);
downloadID = downloadManager.enqueue(request);
Again, this crash is observed only in Galaxy A5 with OS version 5.0.2, in an emulator running Samsung Galaxy S6 with Lollipop and in emulator running Kitkat 4.4.4 HTC One.
The full stack trace :
java.lang.RuntimeException: Unable to start activity ComponentInfo{...players.PDFViewer}: java.lang.SecurityException: need WRITE_EXTERNAL_STORAGE permission to use DESTINATION_FILE_URI: uid 10229 does not have android.permission.WRITE_EXTERNAL_STORAGE.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6145)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.SecurityException: need WRITE_EXTERNAL_STORAGE permission to use DESTINATION_FILE_URI: uid 10229 does not have android.permission.WRITE_EXTERNAL_STORAGE.
at android.os.Parcel.readException(Parcel.java:1540)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:475)
at android.content.ContentResolver.insert(ContentResolver.java:1260)
at android.app.DownloadManager.enqueue(DownloadManager.java:1336)
at de.imsystems.crmmobile.players.PDFViewer.onCreate(PDFViewer.java:104)
at android.app.Activity.performCreate(Activity.java:6374)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6145)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
If you have any thoughts, please share them, thanks in advance.
Eventually this post WRITE_EXTERNAL_STORAGE not working on lollipop even though it's set in the manifest helped me. What I did was to alter permissions in AndroidManifest.xml file like this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="26" tools:replace="android:maxSdkVersion"/>
This way the app doesn't crashes!
I get this error when I press the button for the wifi toggle and the app stops working.It mentions that the user has no permission to access wifi state.The thing is its already declared in the Manifest file.
Permissions used:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Error
FATAL EXCEPTION: main
Process: com.example.something.callblocker, PID: 935
java.lang.SecurityException: WifiService: Neither user 10052 nor current process has android.permission.ACCESS_WIFI_STATE.
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at android.net.wifi.IWifiManager$Stub$Proxy.getWifiEnabledState(IWifiManager.java:808)
at android.net.wifi.WifiManager.getWifiState(WifiManager.java:1029)
at android.net.wifi.WifiManager.isWifiEnabled(WifiManager.java:1041)
at com.example.stamatis.callblocker.powersavings$2.onClick(powersavings.java:55)
at android.view.View.performClick(View.java:4438)
at android.widget.CompoundButton.performClick(CompoundButton.java:100)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
If this is happening and you are saying that android.permission.ACCESS_WIFI_STATE this is already present in manifest, then there is only one possibility that user has explicitly stopped this permission.
Check if this crash is in Marshmallow i.e API 23. Google has provided the user power to remove the permission of app explicitly.
You can read : http://www.greenbot.com/article/2990078/android/how-to-toggle-app-permissions-in-android-marshmallow.html
Only solution is to check for permission at runtime before doing toggle.
This is how you can do this :
private boolean checkWriteExternalPermission()
{
String permission = "android.permission.ACCESS_WIFI_STATE";
int res = getContext().checkCallingOrSelfPermission(permission);
return (res == PackageManager.PERMISSION_GRANTED);
}
Needs to be looked at by authorities for fraud and illegal activity steal the token page
My app was sent a stack trace for device Y625-U21 (HWY625-U), the app doesn't ask for READ_PHONE_STATE because the docs say nothing about using this permission for getting dateFormat. We have tested the app in various devices and this doesn't happen.
java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10149 nor current process has android.permission.READ_PHONE_STATE.
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at com.android.internal.telephony.IPhoneSubInfo$Stub$Proxy.getSubscriberId(IPhoneSubInfo.java:317)
at android.telephony.TelephonyManager.getSubscriberId(TelephonyManager.java:1094)
at android.text.format.DateFormat.getDateFormatStringForSetting(DateFormat.java:262)
at android.text.format.DateFormat.getDateFormatForSetting(DateFormat.java:250)
at android.text.format.DateFormat.getDateFormat(DateFormat.java:236)
at edu.usf.cutr.opentripplanner.android.util.ConversionUtils.getTimeWithContext(ConversionUtils.java:217)
at edu.usf.cutr.opentripplanner.android.util.ConversionUtils.getTimeWithContext(ConversionUtils.java:210)
at edu.usf.cutr.opentripplanner.android.fragments.MainFragment.fillItinerariesSpinner(MainFragment.java:3521)
at edu.usf.cutr.opentripplanner.android.fragments.MainFragment.onTripRequestComplete(MainFragment.java:3462)
at edu.usf.cutr.opentripplanner.android.tasks.TripRequest.onPostExecute(TripRequest.java:171)
at edu.usf.cutr.opentripplanner.android.tasks.TripRequest.onPostExecute(TripRequest.java:60)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5135)
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:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
at dalvik.system.NativeStart.main(Native Method)
I can say that when your app gets a lot of installs in Google Play you will receive a lot of strange crash reports in Google Developer console.
Sometimes there is nothing you can do with it and you have to put your code in try/catch block.
I don't know all the details about your case, but in mine it was the only solution.
try {
//your code here
} catch (SecurityException e) {
e.printStackTrace();
//do smth in this scenario
}
include this permission in manifest file
READ_PHONE_STATE
You are getting this exception becoz you haven't declare this permission in manifest file.
My Logcat:
08-23 01:32:12.806 1299-1299/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.haftasia.easycode, PID: 1299
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxx cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{43f9a738 1299:com.haftasia.easycode/u0a181} (pid=1299, uid=10181) requires android.permission.CALL_PHONE
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2109)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1419)
at android.app.Activity.startActivityForResult(Activity.java:3442)
at android.app.Activity.startActivityForResult(Activity.java:3403)
at android.app.Activity.startActivity(Activity.java:3645)
at android.app.Activity.startActivity(Activity.java:3613)
at com.haftasia.easycode.Day_3G_Mci$1$1.onClick(Day_3G_Mci.java:52)
at android.view.View.performClick(View.java:4448)
at android.view.View$PerformClick.run(View.java:18461)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5065)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
You must add this permission in your AppManifest.xml:
<uses-permission android:name="android.permission.CALL_PHONE" />
Your error occurred because you didn't add it.
Since the logcat is saying everything what you looking for why dont you try to add permission ?
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
You seem to have an intent which makes an call but however for any app to make a call it requires the permission.
To add it in the Manifest before the application tag add the following
<uses-permission android:name = "android.permission.CALL_PHONE"/>