0

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. It's located at http://developer.android.com/samples/Camera2Basic/project.html. I imported the project and have changed the code in build.gradle to

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:

dependencies {
    compile "com.android.support:support-v4:21.0.+"
}
Johnny
  • 656
  • 2
  • 14
  • 24

1 Answers1

0

There could be many errors when executing newest API on older Android version. There could be used functions from API 21 that are not present in API 15 device. Have you changed your project compile api(not only in code but whole project build)? In eclipse its located in project properties -> 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

Karol Żygłowicz
  • 2,202
  • 2
  • 19
  • 30
  • I have the minimum SDK set to 15 and the support libraries added. This should give support for the older API. I'm not sure how to change the API for the project build in Android Studio, if that's even possible. I thought that was supposed to be handled in build.gradle. – Johnny Nov 23 '14 at 18:37
  • have you done steps mentioned here http://stackoverflow.com/questions/19465049/changing-api-level-android-studio ? – Karol Żygłowicz Nov 23 '14 at 18:42
  • Yes, I have. As stated in the selected answer, I update `build.gradle` and then synced, then rebuilt the project. Editing the manifest file should not be necessary and I've never had to do so before. – Johnny Nov 23 '14 at 18:51