[英]How do I get example code from Android to run on an older phone?
I am trying to get the sample camera app, called Camera2Basic, that was released with API 21 to compile on my 4.0.3 (API 15) test phone. 我正在尝试获取名为Camera2Basic的示例相机应用程序,该应用程序与API 21一起发布,可以在我的4.0.3(API 15)测试手机上进行编译。 It's located at http://developer.android.com/samples/Camera2Basic/project.html . 它位于http://developer.android.com/samples/Camera2Basic/project.html 。 I imported the project and have changed the code in build.gradle to 我导入了项目,并将build.gradle中的代码更改为
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
}
I'm getting a lot of errors, the first being: 我遇到很多错误,第一个是:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.camera2basic/com.example.android.camera2basic.CameraActivity}: android.view.InflateException: Binary XML file line #30: Error inflating class com.android.internal.widget.ActionBarView
I have tried researching the errors independently but I feel I'm missing something important. 我尝试过独立研究错误,但是我感觉缺少重要的东西。 Any recommendations? 有什么建议吗?
Edit: I also have added the dependency for the support library to build.gradle: 编辑:我还添加了对支持库build.gradle的依赖项:
dependencies {
compile "com.android.support:support-v4:21.0.+"
}
There could be many errors when executing newest API on older Android version. 在较旧的Android版本上执行最新的API时,可能会出现许多错误。 There could be used functions from API 21 that are not present in API 15 device. 可能有API 15设备中不存在的API 21中使用的功能。 Have you changed your project compile api(not only in code but whole project build)? 您是否更改了项目编译API(不仅在代码中,而且在整个项目构建中)? In eclipse its located in project properties -> Android. 在eclipse中,它位于项目属性-> Android中。 If not thats why you are able to compile this code without errors. 如果不是,那就是为什么您能够无错误地编译此代码。 After change you will see those functions which are not present in API 15 更改后,您将看到API 15中不存在的那些功能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.