消息关闭
    暂无新消息!
新建安卓项目,android.support.design.widget.FloatingActionButton这个控件找不到啊
libs也放了android-support-design.jar文件了,编译生成没问题,运行软件后闪退。



就在布局文件里加载一个FloatingActionButton。

日志
09-06 23:17:21.268: E/AndroidRuntime(14405): FATAL EXCEPTION: main
09-06 23:17:21.268: E/AndroidRuntime(14405): Process: com.example.mytest2, PID: 14405
09-06 23:17:21.268: E/AndroidRuntime(14405): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mytest2/com.example.mytest2.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class android.support.design.widget.FloatingActionButton
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2581)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2656)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.app.ActivityThread.access$800(ActivityThread.java:178)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1512)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.os.Handler.dispatchMessage(Handler.java:111)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.os.Looper.loop(Looper.java:194)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.app.ActivityThread.main(ActivityThread.java:5691)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.reflect.Method.invoke(Native Method)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.reflect.Method.invoke(Method.java:372)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
09-06 23:17:21.268: E/AndroidRuntime(14405): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.support.design.widget.FloatingActionButton
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.view.LayoutInflater.createView(LayoutInflater.java:633)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:430)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.app.Activity.setContentView(Activity.java:2217)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at com.example.mytest2.MainActivity.onCreate(MainActivity.java:13)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.app.Activity.performCreate(Activity.java:6142)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1115)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2528)
09-06 23:17:21.268: E/AndroidRuntime(14405):  ... 10 more
09-06 23:17:21.268: E/AndroidRuntime(14405): Caused by: java.lang.reflect.InvocationTargetException
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.reflect.Constructor.newInstance(Native Method)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.view.LayoutInflater.createView(LayoutInflater.java:607)
09-06 23:17:21.268: E/AndroidRuntime(14405):  ... 21 more
09-06 23:17:21.268: E/AndroidRuntime(14405): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/design/R$styleable;
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:87)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:79)
09-06 23:17:21.268: E/AndroidRuntime(14405):  ... 24 more
09-06 23:17:21.268: E/AndroidRuntime(14405): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.R$styleable" on path: DexPathList[[zip file "/data/app/com.example.mytest2-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
09-06 23:17:21.268: E/AndroidRuntime(14405):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
09-06 23:17:21.268: E/AndroidRuntime(14405):  ... 26 more
09-06 23:17:21.268: E/AndroidRuntime(14405):  Suppressed: java.lang.ClassNotFoundException: android.support.design.R$styleable
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.Class.classForName(Native Method)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
09-06 23:17:21.268: E/AndroidRuntime(14405):  at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
09-06 23:17:21.268: E/AndroidRuntime(14405):  ... 27 more
09-06 23:17:21.268: E/AndroidRuntime(14405):  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

21个回答

︿ 0
ec要把整个design工程文件导入,然后最为一个库文件添加到项目中(选择Exist Android Project),不能只添加一个jar文件啊亲
︿ 0
我是让当前的activity继承AppCompatActivity(这边要把那个v7的包加载进来),并且设置一下主题android:theme="@style/Theme.AppCompat.Light.NoActionBar",之后就可以把FloatingActionButton加载出来了
︿ 0
在build.gradle添加      compile 'com.android.support:design:23.3.0'   从启项目
︿ 0
万能的

http://stackoverflow.com/questions/30964009/classnotfoundexception-didnt-find-class-android-support-design-rstyleable