无法在Android 8 Oreo上获得WAKE_LOCK权限 [英] Cannot get WAKE_LOCK permission on Android 8 Oreo

查看:749
本文介绍了无法在Android 8 Oreo上获得WAKE_LOCK权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序已将<uses-permission android:name="android.permission.WAKE_LOCK" />添加到AndroidManifest.xml.但是,获取锁PowerManager.PARTIAL_WAKE_LOCK的调用使该应用程序在Oreo设备上崩溃.

My app has <uses-permission android:name="android.permission.WAKE_LOCK" /> added to the AndroidManifest.xml. However calls to acquire the lock PowerManager.PARTIAL_WAKE_LOCK crash the app on Oreo devices.

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.SecurityException: Neither user 10094 nor current process has android.permission.WAKE_LOCK.

推荐答案

您的应用可能正在使用ACRA库的新版本.在新版本中,他们将<uses-permission android:name="android.permission.WAKE_LOCK" android:maxSdkVersion="25" />添加到了lib AndroidManifest.xml文件中. android:maxSdkVersion="25"被静默合并到主应用程序AndroidManifest.xml文件中,因此该应用程序在Oreo设备上没有WAKE_LOCK权限.解决方案是将tools:node="replace"添加到您的使用许可声明中.

Your app is probably using a new version of ACRA library. In new the version they added <uses-permission android:name="android.permission.WAKE_LOCK" android:maxSdkVersion="25" /> to the lib AndroidManifest.xml file. The android:maxSdkVersion="25" is silently merged to main app AndroidManifest.xml file, hence the app doesn't have WAKE_LOCK permission on Oreo devices. The solution is add tools:node="replace" to your uses-permission declaration.

例如<uses-permission android:name="android.permission.WAKE_LOCK" tools:node="replace" />.

更新:在最新版本的ACRA库中,不幸的功能"已被已删除 .

Update: in recent versions of ACRA library that unfortunate "feature" has been removed.

这篇关于无法在Android 8 Oreo上获得WAKE_LOCK权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆