简体   繁体   English

Camera2示例应用程序在Lollipop设备上崩溃

[英]Camera2 sample app crashes on Lollipop device

I am trying to run Camera2 sample application https://github.com/googlesamples/android-Camera2Basic on Samsung SM-G900V (Galaxy S5) which is running Lollipop 5.0 API level 21. 我正在尝试在运行Lollipop 5.0 API级别21的三星SM-G900V(Galaxy S5)上运行Camera2示例应用程序https://github.com/googlesamples/android-Camera2Basic

However the application crashes - with following exception. 但是,应用程序崩溃-以下异常。 android.camera2basic E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NoSuchMethodError: No virtual method checkSelfPermission(Ljava/lang/String;)I in class Landroid/app/Activity; or its super classes (declaration of 'android.app.Activity' appears in /system/framework/framework.jar)

If I am reading google's documentation right API 21 should have support for Camera2 APIs.I have also tried same thing with Android emulator and getting similar crash. 如果我正在阅读google的文档权利,API 21应该支持Camera2 API。我也尝试过使用Android模拟器进行同样的操作并遇到类似的崩溃。 Is Camera2 API supposed to work on API21 devices? Camera2 API是否应该在API21设备上运行?

The crash doesn't have anything to do with the camera2 package. 崩溃与camera2camera2

The problem is with the method you are calling to check runtime permissions: the one you are using was only added in API Level 23. This article provides methods to safely check runtime permissions on Android < 23, check the section titled 问题在于您调用的用于检查运行时权限的方法: 您使用的方法仅在API级别23中添加。 本文提供了在Android <23上安全地检查运行时权限的方法,请检查标题为的部分

Use Support Library to make code forward-compatible 使用支持库使代码向前兼容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM