Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Android 4.1 and AppOpsManager #495

Closed
jtroxel opened this issue Jan 13, 2016 · 6 comments
Closed

Android 4.1 and AppOpsManager #495

jtroxel opened this issue Jan 13, 2016 · 6 comments

Comments

@jtroxel
Copy link

jtroxel commented Jan 13, 2016

I am wondering if the support for Android 4.0 and above is accurate. We have push notifications working on several devices 4.4 and above, but on a 4.1 device we see the following, followed by a crash of the app:
E/AndroidRuntime(17781): FATAL EXCEPTION: pool-1-thread-2
E/AndroidRuntime(17781): java.lang.NoClassDefFoundError: android.app.AppOpsManager
E/AndroidRuntime(17781): at com.adobe.phonegap.push.PermissionUtils.hasPermission(PermissionUtils.java:17)
E/AndroidRuntime(17781): at com.adobe.phonegap.push.PushPlugin$3.run(PushPlugin.java:171)
E/AndroidRuntime(17781): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
E/AndroidRuntime(17781): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
E/AndroidRuntime(17781): at java.lang.Thread.run(Thread.java:856)

A little digging, looks like AppOpsManager is only available on sdk19 / 4.4+: http://developer.android.com/reference/android/app/AppOpsManager.html

If we are doing something wrong, we'd love to know, or otherwise if there is a workaround for this. Thanks.

@fredgalvao
Copy link
Collaborator

You're right. That code should be better guarded.

@zwacky Could you take a look into this improvement? I think we can fix this by using reflection similar to this (search for AppOpsManager).

@macdonst
Copy link
Member

@jtroxel Yeah, that's a bug. We can fix it pretty quickly though.

@zwacky
Copy link
Contributor

zwacky commented Jan 13, 2016

yes, this seems off for < 4.4. i can fix this by thursday with using @fredgalvao's suggestion using reflections.

@macdonst
Copy link
Member

@zwacky kk, I'll let you handle it.

@zwacky
Copy link
Contributor

zwacky commented Jan 14, 2016

here we go, tested it on 4.4+ and 4.2. 1557f73

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants