Android: FloatingActionButton could not be instantiated

断了今生、忘了曾经 提交于 2019-12-23 10:06:53

问题


I am trying to use Floating Action Button(FAB) in my application. However, when I am declaring the same I get the error:

android.support.design.widget.FloatingActionButton could not be instantiated.

I have added following commands to my gradle file:

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'

I have also tried with adding following to my style parent:

parent="@style/Theme.AppCompat"

Also tried having my Activity class extend Activity as well as AppCompatActivity.

Am I missing something? Pls. help


回答1:


Android build system uses the Android Plugin for Gradle to support building Android applications with the Gradle build toolkit. The plugin runs independent of Android Studio so the plugin and the Gradle build system can be updated independently of Android Studio.

For FloatingActionButton requirement

Please update your classpath

  dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

    }



回答2:


Must have :

compileSdkVersion 23

&

 dependencies {
            classpath 'com.android.tools.build:gradle:1.5.0'

        }


来源:https://stackoverflow.com/questions/35169837/android-floatingactionbutton-could-not-be-instantiated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!