在eclipse中找不到android.support.design.widget.coordinatorlayout

时间:2015-08-04 11:45:15

标签: android

我正在使用eclips,当我运行我的项目时,我收到以下错误。

08-04 17:12:25.596: E/AndroidRuntime(4175): FATAL EXCEPTION: main
08-04 17:12:25.596: E/AndroidRuntime(4175): java.lang.RuntimeException: Unable to start activity ComponentInfo{me.declangao.wordpressreader/me.declangao.wordpressreader.app.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.os.Looper.loop(Looper.java:137)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.main(ActivityThread.java:5103)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at java.lang.reflect.Method.invokeNative(Native Method)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at java.lang.reflect.Method.invoke(Method.java:525)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at dalvik.system.NativeStart.main(Native Method)
08-04 17:12:25.596: E/AndroidRuntime(4175): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.createView(LayoutInflater.java:620)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at me.declangao.wordpressreader.app.PostFragment.onCreateView(PostFragment.java:72)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.Activity.performStart(Activity.java:5143)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
08-04 17:12:25.596: E/AndroidRuntime(4175):     ... 11 more
08-04 17:12:25.596: E/AndroidRuntime(4175): Caused by: java.lang.reflect.InvocationTargetException
08-04 17:12:25.596: E/AndroidRuntime(4175):     at java.lang.reflect.Constructor.constructNative(Native Method)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.createView(LayoutInflater.java:594)
08-04 17:12:25.596: E/AndroidRuntime(4175):     ... 24 more
08-04 17:12:25.596: E/AndroidRuntime(4175): Caused by: java.lang.NoClassDefFoundError: android.support.design.R$styleable
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:168)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:162)

2 个答案:

答案 0 :(得分:4)

  • 在app libs文件夹中包含android-support-design.jar和android-support-v4.jar。
  • 将设计库导入Eclipse,出现在&lt; sdk&gt; \ extras \ android \ support \ design。
  • 打开项目的属性 - &gt; android - &gt; (图书馆)添加... - &gt;选择设计。
  • 你应该改变
public class YourActivity extends Activity {
}

public class YourActivity extends AppCompatActivity {    
}
  • AndroidManifest.xml并将应用程序的主题更改为
@style/Theme.AppCompat

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat">

答案 1 :(得分:-1)

将其添加到app level中的build.gradle文件中。

编译&#39; com.android.support:design:23.2.1&#39;