Android |二进制XML文件错误膨胀类| Canot使用本地图书馆的课程

时间:2017-08-08 12:17:41

标签: java android xml gradle

我在xml-layout中使用外部.aar libary时遇到问题。

<?xml version="1.0" encoding="utf-8"?>

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">

<android.support.v7.widget.CardView
    android:id="@+id/card_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_margin="5dp"
    android:layout_weight="42.81"
    card_view:cardCornerRadius="2dp"
    card_view:contentPadding="10dp">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="432dp">


        <TextView
            android:id="@+id/txt_subformular_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:textAppearance="@android:style/TextAppearance.Material.Large"
            android:textSize="22sp"
            android:layout_alignBottom="@+id/imageButton"
            android:layout_alignParentStart="true"
            android:layout_marginBottom="21dp" />

        <ImageButton
            android:id="@+id/imageButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="17dp"
            android:background="@null"
            card_view:srcCompat="@drawable/ic_pdf"
            android:layout_alignParentTop="true"
            android:layout_alignParentEnd="true"
            android:layout_marginTop="36dp" />


        <com.github.barteksc.pdfviewer.PDFView
            android:id="@+id/pdfView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>


    </RelativeLayout>
</android.support.v7.widget.CardView>

现在,我将展示我的gradle.build (build.gradle(Project))

allprojects {
repositories {
    jcenter()
    flatDir {
        dirs 'libs'
    }

的build.gradle(APP)

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile(name:'android-pdf-viewer-2.7.0-beta', ext:'aar') }

调试后我收到以下错误:

  

E / AndroidRuntime:致命异常:主要                                                                                   处理:dtks.telekom.de.serviceapp_dev,PID:16314                                                                                   android.view.InflateException:二进制XML文件行#48:错误输出类com.github.barteksc.pdfviewer.PDFView                                                                                       在android.view.LayoutInflater.createView(LayoutInflater.java:633)                                                                                       在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)                                                                                       在android.view.LayoutInflater.rInflate(LayoutInflater.java:806)                                                                                       在android.view.LayoutInflater.rInflate(LayoutInflater.java:809)                                                                                       在android.view.LayoutInflater.rInflate(LayoutInflater.java:809)                                                                                       在android.view.LayoutInflater.inflate(LayoutInflater.java:504)                                                                                       在android.view.LayoutInflater.inflate(LayoutInflater.java:414)                                                                                       at dtks.telekom.de.serviceapp_dev.Adapters.RVAdapter_SubFormular.onCreateViewHolder(RVAdapter_SubFormular.java:43)                                                                                       at dtks.telekom.de.serviceapp_dev.Adapters.RVAdapter_SubFormular.onCreateViewHolder(RVAdapter_SubFormular.java:20)

1 个答案:

答案 0 :(得分:0)

您的CardView代码不正确。没有设置layout_widthlayout_height,也没有关闭角括号。

像这样使用:

<android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_gravity="center"
        android:layout_width="200dp"
        android:layout_height="200dp"
        card_view:cardCornerRadius="4dp">

然后移除CardViewxmlns:tools="http://schemas.android.com/tools"

上方的这一行