简体   繁体   English

如何从Android获取示例代码以在较旧的手机上运行?

[英]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.

相关问题 我如何在Android Studio IDE中获取此数据库连接代码以在手机上运行 - How do i get this database connection code in my android studio IDE to run on my phone 如何从developer.android.com获取示例测试代码(ActivityInstrumentation)来运行? - How do I get the Sample test code (ActivityInstrumentation) from developer.android.com to run? 如何从 android 10,11 java 的电话中获取此信息 - How do I get this information from the phone from android 10,11 java 我似乎无法在旧版的Android手机上运行我的Android Studio项目 - I cannot seem to run my android studio project on an older android phone 如何从电话号码中删除“+”和国家/地区代码? - How do I remove the “+” and country code from a phone number? 从我的Android Java代码示例中,如何将动态ICON添加到来自URL和远程服务器的列表视图中? - From my Android Java Code example How do I add a dynamic ICON to the List View that comes from a URL and remote server? 如何从Android手机读取Java中的CPU“统计信息”? - How do I read CPU “stats” in Java from an Android phone? 如何从此示例HTTP请求获取正文? - How do I get the body from this example HTTP request? 如何从 Java 中运行的进程中获取 bash 命令退出代码? - How do I get the bash command exit code from a Process run from within Java? 如何成功运行 JavaCV 代码示例 (JavaFxPlayVideoAndAudio.java) - How do I successfully run JavaCV code example (JavaFxPlayVideoAndAudio.java)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM