我正在使用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)
答案 0 :(得分:4)
public class YourActivity extends Activity {
}
到
public class YourActivity extends AppCompatActivity {
}
@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;