What I am trying to do is use the new android support design library mentioned here: http://android-developers.blogspot.com/2015/05/android-design-support-library.html.
I have attempted to use the floating action button as follows in my xml layout (this is where the below error is coming from):
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/adview"
android:layout_marginTop="500dp" />
When my app is launched this is the error:
06-06 20:56:43.186 6405-6405/com.nick.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.nick.app, PID: 6405
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nick.app/com.nick.app.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2366)
at android.app.ActivityThread.access$800(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5290)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.design.widget.FloatingActionButton
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:401)
at android.app.Activity.setContentView(Activity.java:2197)
at com.nick.app.MainActivity.onCreate(MainActivity.java:94)
at android.app.Activity.performCreate(Activity.java:6020)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2366)
at android.app.ActivityThread.access$800(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5290)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
in my build.gradle
file for the app module I have compile 'com.android.support:design:22.2.0'
as required.Also, other relevant parts from the build.gradle
file:
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 21
.....
I should also note that when I go to project structure->dependencies and I try to add a library dependency I cannot find "com.android.support:design:22.2.0" when searching (I am not sure if this is required in addition to adding the dependency in build.gradle file).
Finally, in my SDK manager I have confirmed "Android Support Repository" and "Android Support Library" are up to date at versions 15 and 22.2, respectively.
Are there any suggestions for what else I might try?
I have found this answer: https://stackoverflow.com/a/30557995/1489990 and tried the solution however it did not solve my issue.