Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Permission denial reading #14

Closed
ghost opened this issue Jul 8, 2016 · 12 comments
Closed

Android: Permission denial reading #14

ghost opened this issue Jul 8, 2016 · 12 comments

Comments

@ghost
Copy link

ghost commented Jul 8, 2016

Hi,
on my android testphone - were it worked until now - i get this exception:

Error: java.lang.SecurityException: Permission Denial: reading
com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/display_photo/2 from pid=26745, uid=10441 requires android.PERMISSION.READ_CONTACTS or grantUriPermission()

Permissions are not added to AndroidManifest.xml, if i add them by hand i still get the same error.

Also tried these suggstions: http://stackoverflow.com/questions/8104776/permission-read-contacts-does-not-seem-to-work - no success

Any hints?

@ghost
Copy link
Author

ghost commented Jul 8, 2016

Building with AndroidStudio gave a better hint @firescript:

Warning:The file: /home/mre/PROJECTS/test/node_modules/nativescript-contacts/platforms/android/AndroidManifest.xml is depricated, you can read more about what will be the expected plugin structure here: https://www.nativescript.org/blog/migrating-n-android-plugins-from-version-1.7-to-2.0

@PeterStaev
Copy link
Collaborator

Hey @einicher , although CLI throws this warning, it is a false one, as it was decided to keep AndroidManifest for plugins. You can read more here.

Have you installed the plugin using tns install nativescript-contacts? Also can you try to clean your android platforms and then building your project again:

tns platform clean android
tns deploy android

@ghost
Copy link
Author

ghost commented Jul 8, 2016

i did several times.

rm -rf node_modules platforms
tns platform add android
tns run android

same outcome, it shows me the contact selection dialog, but when i pick a contact i get the permission denied exception.

@ghost
Copy link
Author

ghost commented Jul 8, 2016

is it possible it has something to with

sudo npm install -g nativescript
npm install tns-core-modules@latest --save

i suddenly have to do this everytime i start a new project or else i get the error “app.js not found”

@sitefinitysteve
Copy link
Collaborator

It's this android 6?
On Jul 8, 2016 9:45 AM, "Markus René Einicher" notifications@github.com
wrote:

i did several times.

rm -rf node_modules platforms
tns platform add android
tns run android

same outcome, it shows me the contact selection dialog, but when i pick a
contact i get the permission denied exception.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#14 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABeI6HrxMibBmEOZuo_tLTLwDxDiCck1ks5qTlSQgaJpZM4JH8xg
.

@ghost
Copy link
Author

ghost commented Jul 8, 2016

@sitefinitysteve
yes, android version 6.0.1

@sitefinitysteve
Copy link
Collaborator

Can you try this? https://www.npmjs.com/package/nativescript-permissions
On Jul 8, 2016 10:04 AM, "Markus René Einicher" notifications@github.com
wrote:

@sitefinitysteve https://github.com/sitefinitysteve
yes, android version 6.0.1


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#14 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABeI6K1Oi7WKJbrIdcCbK5sIR4BNu0P6ks5qTljdgaJpZM4JH8xg
.

@ghost
Copy link
Author

ghost commented Jul 8, 2016

@sitefinitysteve “Woo Hoo, I have the power”
it works.
Very important contribution, I would have nver thought about that, I thought it asks by itself, like qr-plugin does.
thx!!

@sitefinitysteve
Copy link
Collaborator

I'll see what i can do, or at least document it
On Jul 8, 2016 10:23 AM, "Markus René Einicher" notifications@github.com
wrote:

@sitefinitysteve https://github.com/sitefinitysteve “Woo Hoo, I have
the power”
it works.
Very important contribution, I would have nver thought about that, I
thought it asks by itself, like qr-plugin does.
thx!!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#14 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABeI6E6ASiJi-dkyKNOFO63r12WL27Efks5qTl1kgaJpZM4JH8xg
.

@koganalon
Copy link

You'll need a Runtime permission.
with or without placing the permission in your manifest, You will need to request that permission from the User on-the-fly.

if( getApplicationContext().checkSelfPermission( Manifest.permission.READ_CONTACTS ) != PackageManager.PERMISSION_GRANTED )
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.READ_CONTACTS}, resultValue);

only then after the approval you will be able to query the contacts phone number/name etc.

@jzgoda
Copy link
Collaborator

jzgoda commented Apr 18, 2019

Docs have been updated to avoid this issue.

@jzgoda jzgoda closed this as completed Apr 18, 2019
@hinalt
Copy link

hinalt commented Nov 17, 2020

I still get this error. Can you please paste an working example to explain this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants