2017-11-20 15 views
1

次のコードでは、<アンドロイド21のエラー膨張クラスandroid.support.v7.widget.CardViewは、(ロリポップ)アンドロイドよりも大きい21にうまく機能しているバイナリXMLファイルライン#2:アンドロイドスタジオ

@Override 
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 

    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_course_not_bought, parent, false); 

    return new ViewHolder(v); 
} 

しかしアンドロイド< 21でクラッシュを作る...

私はアンドロイドのスタジオを使用して、CardView

のライブラリ
11-20 13:39:43.418 5851-5851 E/AndroidRuntime: FATAL EXCEPTION: main 
              android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.CardView 
               at android.view.LayoutInflater.createView(LayoutInflater.java:613) 
               at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
               at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 
               at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
               at ir.dpsoft.lms.RecyclerViewAdapter.RecyclerNotBoughtCourses.onCreateViewHolder(RecyclerNotBoughtCourses.java:55) 
               at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6488) 
               at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5675) 
               at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5558) 
               at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5554) 
               at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2229) 
               at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1556) 
               at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1516) 
               at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:583) 
               at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3694) 
               at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3110) 
               at android.view.View.measure(View.java:15518) 
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) 
               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) 
               at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) 
               at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) 
               at android.view.View.measure(View.java:15518) 
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) 
               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) 
               at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) 
               at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) 
               at android.view.View.measure(View.java:15518) 
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) 
               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) 
               at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) 
               at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) 
               at android.view.View.measure(View.java:15518) 
               at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1217) 
               at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
               at android.widget.ScrollView.onMeasure(ScrollView.java:321) 
               at android.view.View.measure(View.java:15518) 
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) 
               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) 
               at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) 
               at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) 
               at android.view.View.measure(View.java:15518) 
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) 
               at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
               at android.view.View.measure(View.java:15518) 
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) 
               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) 
               at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) 
               at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) 
               at android.view.View.measure(View.java:15518) 
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) 
               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) 
               at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) 
               at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) 
               at android.view.View.measure(View.java:15518) 
               at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1060) 
+0

あなたのxmlファイル – Kuls

+0

が、これは完全なlogcatであることを示しますか?通常は「原因」に関する詳細があります –

+0

あなたのgraddleファイルを表示 – diegoveloper

答えて

0

をインポートあなたのGradleファイルにこれらの依存関係を追加します。

compile 'com.android.support:appcompat-v7:27.0.0' 
    compile 'com.android.support:cardview-v7:27.0.0' 

以前のバージョンの互換性については、このマニュアルを参照してください:

https://developer.android.com/training/material/compatibility.html

+0

これがどのように役立つかを説明してください。コードがうまくコンパイルされ –

+0

私は互換性について読んでいた:https://developer.android.com/training/material/compatibility.html – diegoveloper

+0

質問はこれらのライブラリはすでに –

関連する問題