Permission denied, AndroidManifest.xml does not work - android

m developing launcher for 2.3.3 via specified STB. And I wrote permissions like
...
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...
in AndroidManifest.xml.
While debugging -uninstall/install-, sometimes meet "Permission denied" so i should uninstall/install again and again till got no errors with "Permission denied".
Does anyone get this strange bug? Of course, I did not edit AndroidManifest.xml at all.

If while debugging your Device is connected to a PC and
Enable copy files to/from your computer.
Then you will see this Permission denied message.

I have had recently this problem, when I upgraded the targetSdkVersion to 23. The "problem" was the new system of dynamic permissions in Android. See http://developer.android.com/training/permissions/requesting.html

Related

Android: java.net.SocketException: Permission denied

Some of my app users are seeing the "Permission denied" exception
Specially for the following device: Xiaomi MI MAX Android OS: 7.0
Other devices are able to access Internet.
I've added the required permissions before the application tag, like this,
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application>
...
</application>
Can anyone please help what is wrong here?
For Android 6.0 and above, there is a new way of requesting permission from the user, which is called runtime permission, which means permission is granted when the app is running, not when it is installed like earlier versions.
Check the official guide for complete explanation

No prompt or toggle for Android permission

In my app on Android 7, targetSdkVersion 24, I am trying to request an Android permission WRITE_EXTERNAL_STORAGE. However, when I run the app, it never prompts me for this permission, and when on my device I go to Settings > Apps > MyApp > Permissions, I do not see a toggle for anything related to WRITE_EXTERNAL_STORAGE.
Have I missed a step somewhere?
AndroidManifest.xml (complete file on pastebin)
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
MyActivity.java
int permission = activity.checkSelfPermission(perm);
if (permission != PackageManager.PERMISSION_GRANTED)
activity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
After spending some time to investigate, I have developed a theory on this issue.
My app has some dependencies that has this in their AndroidManifest.xml:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
What this does is auto deny WRITE_EXTERNAL_STORAGE permission if the SDK is higher than 18. That's consistent with the issues I am getting; Permission getting denied and not even prompt the user.
Then I test adding this to my App AndroidManifest.xml in attempt to override the lib dependency permission settings:
android:maxSdkVersion="25"
It then fails to build due to Merge conflict on masSdkVersion. This further confirms my suspicions on the issue; the android:maxSdkVersion propagated to the App module.
After digging through the docs, I can't find the solution, but I have a work around. READ_EXTERNAL_STORAGE is in the same group as the WRITE_EXTERNAL_STORAGE, and the doc says asking a permission for the same group would apply to the rest of permission for the whole group.
So I tested asking READ permission throughout my App and AndroidManifest.xml, it works, but I think it's stupid.
I will update when I find a proper way to resolved.

java.lang.SecurityException despite INTERNET permission being in the manifest

I am getting the following error when I run my application on my phone:
java.lang.SecurityException: Permission denied (missing INTERNET permission?)
I have already added that permission in my manifest file as follows:
<uses-permission android:name="ANDROID.PERMISSION.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I am getting the error only when I run the app on my phone. It runs fine on my GenyMotion emulator. I read similar questions on SO before posting it. Also, I have made a couple of apps before with same permissions, and this error had never occurred then. So I don't get why Android is messing it up this time.
P.S.: I updated my SDK tools before starting with this new application. Somehow felt that it was important to mention it!
Use small caps
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

How to fix HARDWARE_TEST permission error?

i'm developing an android app which uses some hardware parts like camera or Wi-Fi, and i'm using HARDWARE_TEST permission in the manifiest:
<uses-permission android:name="android.permission.HARDWARE_TEST">
I never have had any issue with that, but now suddenly when I eclipse and manifiest file, a new error is shown in this line:
"Permission is only granted to system apps"
The only way i've got to fix it is deleting this line.
Why is this error?? How can I fix it?
Thanks
Edited:
I have found the solution and answer my own question:
My problem was in android:targetSdkVersion value in manifiest which was 15 and proyect build target was checked API level 16 (Android 4.1.2)
<uses-sdk
android:minSdkVersion="2"
android:targetSdkVersion="15" />
So i have changed android:targetSdkVersion value to 16 and Proyect properties > Android > "Proyect Buid Target" checked 16 too.
There are several permission protection level for Android Permissions: Normal, Dangerous, System and signatureOrSystem.
signatureOrSystem Permission can only be granted to System applications. And For permissions in signature level:
A permission that the system grants only if the requesting application
is signed with the same certificate as the application that declared
the permission. If the certificates match, the system automatically
grants the permission without notifying the user or asking for the
user's explicit approval.
Here is the permission definition syntax.
Here is the definition of the HARDWARE_TEST permission:
<!-- Allows access to hardware peripherals. Intended only for hardware testing -->
<permission android:name="android.permission.HARDWARE_TEST"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="signature"
android:label="#string/permlab_hardware_test"
android:description="#string/permdesc_hardware_test" />
It is a signature permission in Android 4.2, so it can only be granted to app with the same signature(signed by vendor). So your application cannot request that permission.
If you want to directly manipulate hardware, you may need a rooted device.

Exception in android manifest file permission

I got exception in android manifest file.
I have added following permissions:
1. uses-permission android:name="android.permission.CALL_PRIVILEGED" />
2. uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
I got
"Permission is only granted to system apps" error. How to fix it. Before it was working fine.
you can't fix it. As mentioned:
"Permission is only granted to system apps"
This mean, no ordinary app can use the permissions. At least, not without rooting the device.

Categories

Resources