android - 拒绝访问属性“vendor.camera.aux.packagelist”
问题描述
应用程序运行,但是当我尝试使用相机时,只出现一个受干扰的灰色屏幕,并且日志选项卡给了我两个错误:
E/libc: Access denied finding property "vendor.camera.aux.packagelist"
Access denied finding property "vendor.camera.aux.packagelist2"
AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
build.gradle(模块:应用程序)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
}
build.gradle(项目:相机)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
解决方案
首先,检查您的 Android 版本。如果它在 Android 6.0 及更高版本(API 级别 23+)上运行,那么您需要:
在应用清单中声明权限。确保在应用程序标签上方插入权限。
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<application ...>
...
</application>
然后,请求用户在运行时批准每个权限
if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.CAMERA},
50); }
推荐阅读
- aws-lambda - Maximum size for environment variable
- r - (v)matchPattern DNAStringSetList of Codons to Reference DNAString
- file-upload - Twitter 如何将多部分文件从客户端应用程序上传到其存储?
- ios - 分配给 id 的不兼容指针类型
_Nullable' 来自“类” - kubernetes - Terraform 错误创建主题:googleapi:错误 403:用户无权执行此操作
- javascript - 使用单元测试 Jest 时 useCallback 函数不是函数
- mongodb - MongoDB 4.2 版从不是聚合字段之一的聚合函数中获取字段值
- google-cloud-build - CloudBuild Github PR 工作流已排队并且无限期运行
- release - 无法生成 iOS ipa 文件
- flutter - 根据 Dart 中的布尔表达式设置不同的变量