Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNhat Pham
14,848 PointsStormy HourlyForecastActivity crashed . RecycleView InflateException
07-21 01:11:25.258: E/AndroidRuntime(2490): FATAL EXCEPTION: main
07-21 01:11:25.258: E/AndroidRuntime(2490): Process: com.example.testrc, PID: 2490
07-21 01:11:25.258: E/AndroidRuntime(2490): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testrc/com.example.testrc.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class android.support.v7.widget.RecyclerView
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.os.Handler.dispatchMessage(Handler.java:102)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.os.Looper.loop(Looper.java:136)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.app.ActivityThread.main(ActivityThread.java:5001)
07-21 01:11:25.258: E/AndroidRuntime(2490): at java.lang.reflect.Method.invokeNative(Native Method)
07-21 01:11:25.258: E/AndroidRuntime(2490): at java.lang.reflect.Method.invoke(Method.java:515)
07-21 01:11:25.258: E/AndroidRuntime(2490): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-21 01:11:25.258: E/AndroidRuntime(2490): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-21 01:11:25.258: E/AndroidRuntime(2490): at dalvik.system.NativeStart.main(Native Method)
07-21 01:11:25.258: E/AndroidRuntime(2490): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.support.v7.widget.RecyclerView
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
07-21 01:11:25.258: E/AndroidRuntime(2490): at com.example.testrc.MainActivity.onCreate(MainActivity.java:13)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.app.Activity.performCreate(Activity.java:5231)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
07-21 01:11:25.258: E/AndroidRuntime(2490): ... 11 more
07-21 01:11:25.258: E/AndroidRuntime(2490): Caused by: java.lang.reflect.InvocationTargetException
07-21 01:11:25.258: E/AndroidRuntime(2490): at java.lang.reflect.Constructor.constructNative(Native Method)
07-21 01:11:25.258: E/AndroidRuntime(2490): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
07-21 01:11:25.258: E/AndroidRuntime(2490): ... 22 more
07-21 01:11:25.258: E/AndroidRuntime(2490): Caused by: java.lang.NoClassDefFoundError: android.support.v7.recyclerview.R$styleable
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:434)
07-21 01:11:25.258: E/AndroidRuntime(2490): at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:404)
07-21 01:11:25.258: E/AndroidRuntime(2490): ... 25 more
1 Answer
Jon Kussmann
Courses Plus Student 7,254 PointsHi Nhat,
Could you post your MainActivity code?
Nhat Pham
14,848 PointsNhat Pham
14,848 Pointspackage evich.app.stormy;
public class MainActivity extends AppCompatActivity {
}
Nhat Pham
14,848 PointsNhat Pham
14,848 PointsI try to create a new project and still get this exception :
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.support.v7.widget.RecyclerView Caused by: java.lang.reflect.InvocationTargetException Caused by: java.lang.NoClassDefFoundError: android.support.v7.recyclerview.R$styleable
Jon Kussmann
Courses Plus Student 7,254 PointsJon Kussmann
Courses Plus Student 7,254 PointsHi, can you explain how the error occurs? Is it right when the app opens, or when you press something?
Jon Kussmann
Courses Plus Student 7,254 PointsJon Kussmann
Courses Plus Student 7,254 PointsI see, have you made sure you added the recyclerview to your gradle file?
Nhat Pham
14,848 PointsNhat Pham
14,848 PointsHi Jon , when i press Hourly button to switch to HourlyActivity , this error occurs and my app crashed
Jon Kussmann
Courses Plus Student 7,254 PointsJon Kussmann
Courses Plus Student 7,254 PointsOh, can you post the code to that activity then?
Nhat Pham
14,848 PointsNhat Pham
14,848 Pointspublic class HourlyForecastActivity extends AppCompatActivity {
}
Jon Kussmann
Courses Plus Student 7,254 PointsJon Kussmann
Courses Plus Student 7,254 PointsNhat,
In your xml file for your HourlyActivity... is the recyclerview called "recycleview" or "recyclerview"?
Nhat Pham
14,848 PointsNhat Pham
14,848 PointsI'm using Eclipse because my androidstudio is slowly so i add recyclerview library "android-support-v7-recyclerview.jar" (C:\Program Files (x86)\Android\android-sdk\extras\android\support\v7\recyclerview\libs) to my project in eclipse to use
Nhat Pham
14,848 PointsNhat Pham
14,848 PointsHere is my xml file :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="evich.app.stormy.HourlyForecastActivity" >
</RelativeLayout>
Jon Kussmann
Courses Plus Student 7,254 PointsJon Kussmann
Courses Plus Student 7,254 PointsIt looks like the error could be that the height of your recyclerview should be "match_parent" instead of "wrap_content"
Nhat Pham
14,848 PointsNhat Pham
14,848 PointsHi Jon, i'm still getting this error ... It seem android-support-v7-recyclerview.jar has some problems
Jon Kussmann
Courses Plus Student 7,254 PointsJon Kussmann
Courses Plus Student 7,254 PointsIt's not showing in the xml posted, but is your Recyclerview contained within a RelativeLayout?
Nhat Pham
14,848 PointsNhat Pham
14,848 PointsIt's exactly the same in tutorial video , yes my Recyclerview contained within a RelativeLayout
Jon Kussmann
Courses Plus Student 7,254 PointsJon Kussmann
Courses Plus Student 7,254 PointsWhen I did the tutorial, my activity looked like this:
Maybe try posting your HourAdapter class?
Nhat Pham
14,848 PointsNhat Pham
14,848 PointsThat's ok, i will try to update my library or androidsdk , google to solve the problem. Thanks for your help . I am grateful to you, have a nice day