Использование CardView и RecyclerView в моих раскладка бросает исключение

? tolgap @ | Original: StackOverFlow
---

Так что я снимка в материальной Дизайн Android Preview L. Я импортировал оба CardView и RecyclerView библиотеки.

Я использую Android Studio Просмотр версии 0.8.0 . Есть последние SDK пакеты установлены.

После того, как я использую их в моих раскладка, хотя,просмотрщик бросает исключение для них обоих.

Вотисключением для «____» :

CardView

А вотисключение для java.lang.ClassFormatError: Illegal field name "CardView.Dark" in class android/support/v7/cardview/R$style at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:792) at java.lang.ClassLoader.defineClass(ClassLoader.java:635) at org.jetbrains.android.uipreview.ProjectClassLoader.findClass(ProjectClassLoader.java:63) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:411) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at android.support.v7.widget.CardView.initialize(CardView.java:69) at android.support.v7.widget.CardView.<init>(CardView.java:60) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:375) at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:100) at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132) at android.view.LayoutInflater.inflate(LayoutInflater.java:478) at android.view.LayoutInflater.inflate(LayoutInflater.java:381) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:395) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:329) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332) at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:575) at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:564) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932) at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:564) at com.android.tools.idea.rendering.RenderService.render(RenderService.java:691) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:586) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1900(AndroidLayoutPreviewToolWindowManager.java:80) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6$1.run(AndroidLayoutPreviewToolWindowManager.java:528) at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178) at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212) at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6.run(AndroidLayoutPreviewToolWindowManager.java:523) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310) at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.Alarm$Request$1.run(Alarm.java:327) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) :

RecyclerView

Это делает построение макета практически невозможно с помощью этих двух ( Amazing) java.lang.NullPointerException at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:1310) at android.view.View.measure(View.java:16987) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:722) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:458) at android.view.View.measure(View.java:16987) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257) at android.widget.FrameLayout.onMeasure(FrameLayout.java:314) at android.view.View.measure(View.java:16987) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257) at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:447) at android.view.View.measure(View.java:16987) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1083) at android.widget.LinearLayout.onMeasure(LinearLayout.java:615) at android.view.View.measure(View.java:16987) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:16987) at android.widget.LinearLayout.measureVertical(LinearLayout.java:875) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:16987) at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:621) at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:521) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:331) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332) at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:575) at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:564) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932) at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:564) at com.android.tools.idea.rendering.RenderService.render(RenderService.java:691) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:586) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1900(AndroidLayoutPreviewToolWindowManager.java:80) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6$1.run(AndroidLayoutPreviewToolWindowManager.java:528) at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178) at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212) at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171) at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6.run(AndroidLayoutPreviewToolWindowManager.java:523) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310) at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.Alarm$Request$1.run(Alarm.java:327) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) с, что я больше всего интересно .

Естьисправить это уже, или это на самом деле ожидаемое поведение, видя, как они " обычай" View с, в некотором смысле ?

---

Top 5 ответ

1user7610 @

Этоошибка в Android Studio. Тестер не знает, как инициализировать виджеты. Я верю в это, потому чтото же самое исключение из вашего приложения, если вы забыли назвать View в коде .

2Vamsi Challa @

Я использую Eclipse, и столкнулся с такой же вопрос. Как полагает user7610, вам нужно позвонить recyclerView.setLayoutManager(), чтобы получить по этому поводу.

Вот как я решил его ..

Создать переменную-член ..

recyclerView.setLayoutManager()

В RecyclerView.LayoutManager mLayoutManager; или onCreate()

onCreateView()

Это решить мою recyclerView = (RecyclerView) view .findViewById(R.id.business_recycler_view); recyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(getActivity()); recyclerView.setLayoutManager(mLayoutManager); .

3user3716835 @

Если кто-то сталкивается с теми же вопрос для Recycler зрения внутри фрагмента использовать этот код

NullPointerException