web-dev-qa-db-fra.com

Erreur lors du gonflement de la classe - NestedScrollView - classe non trouvée

En cours d'exécution Android Studio 2.1.2, Windows 7.

J'ai remplacé un ScrollView par un NestedScrollView et maintenant je reçois

Android.view.InflateException: ligne de fichier XML binaire # 2: erreur de gonflement de la classe NestedScrollView

Java.lang.ClassNotFoundException: n'a pas trouvé la classe "Android.view.NestedScrollView" sur le chemin: /data/app/com.assemblyguide.remote-48.apk

... lorsque j'appelle SetContentView () sur ce fichier XML. Je ne l'ai pas obtenu alors que je n'avais qu'un ScrollView.

J'ai essayé de nettoyer et d'invalider le cache et de reconstruire. Le XML ressemble à ceci. . .

<?xml version="1.0" encoding="utf-8"?>
<NestedScrollView xmlns:Android="http://schemas.Android.com/apk/res/Android"
    Android:layout_width="wrap_content"
    Android:layout_height="match_parent"
    Android:orientation="vertical" >

    <!-- This linear layout is because the scrollview can have only 1 direct child -->
    <LinearLayout xmlns:Android="http://schemas.Android.com/apk/res/Android"
        Android:layout_width="wrap_content"
        Android:layout_height="wrap_content"
        Android:orientation="vertical" >

        <!-- Relative layout for Workorder -->
        <RelativeLayout
            Android:id="@+id/rellayWorkorder"
            Android:background="#383838"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_marginTop="30dp"
            Android:layout_marginBottom="2dp">
            <TextView
                Android:id="@+id/workorderlabel"
                Android:layout_width="wrap_content"
                Android:layout_height="wrap_content"
                Android:layout_alignParentLeft="true"
                Android:layout_margin="2dp"
                Android:gravity="left"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:text="Work Order:"/>

            <TextView
                Android:id="@+id/workorderContent"
                Android:layout_width="150dp"
                Android:layout_height="wrap_content"
                Android:layout_alignParentRight="true"
                Android:layout_margin="2dp"
                Android:gravity="right"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:text="---workorder---"/>
        </RelativeLayout>


        <!-- Relative layout for Required Time
   <FrameLayout
       Android:layout_width="match_parent"
       Android:layout_height="wrap_content"
       Android:layout_gravity="center_horizontal"></FrameLayout> -->

        <RelativeLayout
            Android:id="@+id/rellayRequiredTime"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_marginTop="30dp"
            Android:layout_marginBottom="2dp">
            <TextView
                Android:id="@+id/requiredTimelabel"
                Android:layout_width="wrap_content"
                Android:layout_height="wrap_content"
                Android:layout_alignParentLeft="true"
                Android:layout_margin="2dp"
                Android:gravity="left"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:text="Required Time:"/>

            <TextView
                Android:id="@+id/requiredTimeContent"
                Android:layout_width="150dp"
                Android:layout_height="wrap_content"
                Android:layout_alignParentRight="true"
                Android:layout_margin="2dp"
                Android:gravity="right"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:text="--- 00 minutes ---"/>
        </RelativeLayout>

        <!-- Relative layout for Time remaining -->
        <RelativeLayout
            Android:id="@+id/rellayTimeRemaining"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_marginTop="30dp"
            Android:layout_marginBottom="2dp">
            <TextView
                Android:id="@+id/timeremaininglabel"
                Android:layout_width="wrap_content"
                Android:layout_height="wrap_content"
                Android:layout_alignParentLeft="true"
                Android:layout_margin="2dp"
                Android:gravity="left"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:text="Time Remaining:"/>

            <TextView
                Android:id="@+id/tviewtimeremainingContent"
                Android:layout_width="150dp"
                Android:layout_height="wrap_content"
                Android:layout_alignParentRight="true"
                Android:layout_margin="2dp"
                Android:gravity="right"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:text="--- 0:00:00---"/>
        </RelativeLayout>

        <!--  Linear layout for Record Start / Record End buttons -->
        <LinearLayout
            Android:orientation="horizontal"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_marginTop="10dp"  >
            <Button
                Android:id="@+id/debulkrecordStart"
                Android:layout_width="150dp"
                Android:layout_height="wrap_content"
                Android:layout_marginTop="6dp"
                Android:layout_marginRight="4dp"
                Android:gravity="center"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:onClick="OnSetRecordStartTimeClick"
                Android:text="Record Start"/>
            <Button
                Android:id="@+id/debulkrecordEnd"
                Android:layout_width="150dp"
                Android:layout_height="wrap_content"
                Android:layout_marginTop="6dp"
                Android:layout_marginRight="4dp"
                Android:gravity="center"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:onClick="OnSetRecordEndTimeClick"
                Android:text="Record End"/>
        </LinearLayout>

        <!-- Relative layout for Vacuum level -->
        <RelativeLayout
            Android:id="@+id/rellayvacuumlevel"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_marginBottom="2dp">
            <TextView
                Android:id="@+id/vaclabel"
                Android:layout_width="wrap_content"
                Android:layout_height="wrap_content"
                Android:layout_alignParentLeft="true"
                Android:layout_margin="2dp"
                Android:gravity="left"
                Android:textAppearance="?android:attr/textAppearanceSmall"
                Android:text="Vacuum Level (inches Hg):"/>
            <EditText
                Android:id="@+id/vacleveledit"
                Android:layout_width="120dp"
                Android:layout_height="wrap_content"
                Android:layout_alignParentRight = "true"
                Android:layout_margin="2dp"
                Android:gravity="left"
                Android:textAppearance="?android:attr/textAppearanceSmall"
                Android:inputType="text|textCapCharacters"
                Android:text="vac level"
                Android:layout_marginRight="2dp"
                Android:layout_marginTop="2dp"
                Android:layout_marginBottom="2dp"/>
        </RelativeLayout>

        <!-- Relative layout for Vac Gauge Equipment # -->
        <RelativeLayout
            Android:id="@+id/rlayvacuumGauge"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_marginBottom="2dp">
            <TextView
                Android:id="@+id/vacgaugelabel"
                Android:layout_width="wrap_content"
                Android:layout_height="wrap_content"
                Android:layout_alignParentLeft="true"
                Android:layout_margin="2dp"
                Android:gravity="left"
                Android:textAppearance="?android:attr/textAppearanceSmall"
                Android:text="Vac Gauge Equipment #:"/>
            <EditText
                Android:id="@+id/vacgaugeedit"
                Android:layout_width="120dp"
                Android:layout_height="wrap_content"
                Android:layout_alignParentRight = "true"
                Android:layout_margin="2dp"
                Android:gravity="left"
                Android:textAppearance="?android:attr/textAppearanceSmall"
                Android:inputType="text|textCapCharacters"
                Android:text="equip. #"/>
        </RelativeLayout>



        <!-- Relative layout for Calibration Due date -->
        <RelativeLayout
            Android:id="@+id/rlaycalibdue"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_marginBottom="2dp">
            <TextView
                Android:id="@+id/calibduelabel"
                Android:layout_width="wrap_content"
                Android:layout_height="wrap_content"
                Android:layout_alignParentLeft="true"
                Android:layout_margin="2dp"
                Android:gravity="left"
                Android:textAppearance="?android:attr/textAppearanceSmall"
                Android:text="Calibration Due Date:"/>
            <EditText
                Android:id="@+id/calibdueedit"
                Android:layout_width="120dp"
                Android:layout_height="wrap_content"
                Android:layout_alignParentRight = "true"
                Android:layout_margin="2dp"
                Android:gravity="left"
                Android:textAppearance="?android:attr/textAppearanceSmall"
                Android:inputType="text|textCapCharacters"
                Android:text="mm/dd/yyyy"/>
        </RelativeLayout>


        <CalendarView
            Android:id="@+id/debulkcalendar"
            Android:layout_width="300dp"
            Android:layout_height="250dp"
            Android:minDate="01/01/2016"
            Android:maxDate="11/30/2016"
            />


        <!--  this linear layout is for the debulk override and done buttons  -->
        <LinearLayout
            Android:orientation="horizontal"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_marginTop="10dp"  >
            <Button
                Android:id="@+id/debulkOverride"
                Android:layout_width="150dp"
                Android:layout_height="wrap_content"
                Android:layout_marginTop="6dp"
                Android:layout_marginRight="4dp"
                Android:onClick="OnResetClick"
                Android:gravity="center"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:text="Override"/>
            <Button
                Android:id="@+id/debulkDone"
                Android:layout_width="150dp"
                Android:layout_height="wrap_content"
                Android:layout_marginTop="6dp"
                Android:layout_marginRight="2dp"
                Android:onClick="onDoneBtnClick"
                Android:gravity="center"
                Android:textAppearance="?android:attr/textAppearanceMedium"
                Android:text="Done"/>
        </LinearLayout>

    </LinearLayout>

</NestedScrollView>

Que signifie cette erreur et comment la corriger?

15
user316117

Le nom complet de la classe est Android.support.v4.widget.NestedScrollView. Remplace le <NestedScrollView> élément avec <Android.support.v4.widget.NestedScrollView> et cela devrait fonctionner correctement. Assurez-vous également d'avoir la bibliothèque de support v4 dans votre fichier build.gradle.

25
chessdork

Si vous utilisez androidx, remplacez <NestedScrollView> ou nom complet de la classe <Android.support.v4.widget.NestedScrollView>avec
<androidx.core.widget.NestedScrollView>

11
Claytog

Vous devez ajouter cette ligne dans les dépendances:

compile 'com.Android.support:support-v4:23.4.0'

Comme l'a dit chessdork, c'est Android.support.v4.widget.NestedScrollView pas NestedScrollView

6
Muhammad Ashraf

Changez-le en

    <androidx.core.widget.NestedScrollView
        Android:layout_width="match_parent"
        Android:layout_height="wrap_content">
3
eng mohamed emam

lorsque j'utilise androidx.core.widget.NestedScrollView, j'ai supprimé cette ligne, cela fonctionnera bien. lorsque j'ajoute cela, l'application se bloque (ma mise en page a également une vue de recyclage dans NestedScrollView)

Android:nestedScrollingEnabled="false"
1
Hien.Nguyen

NestedScrollView a été ajouté dans version 22.1.
Vous devez utiliser NestedScrollView de la manière suivante:

<?xml version="1.0" encoding="utf-8"?>
<Android.support.v4.widget.NestedScrollView xmlns:Android="http://schemas.Android.com/apk/res/Android"
    Android:layout_width="match_parent"
    Android:layout_height="match_parent">

</Android.support.v4.widget.NestedScrollView>

build.gradle (module)

dependencies {
    implementation 'com.Android.support:appcompat-v7:<greater than or equal to 22.1.0>'
    //...
}
0
yoAlex5