Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to finalize session : INSTALL_FAILED_INVALID_APK: Split lib_slice_0_apk was defined multiple times

I'm trying to use Constraint Layout. The Gradle build finished successfully. But I got "Error installing APK" with following code:

Failed to finalize session : INSTALL_FAILED_INVALID_APK: Split lib_slice_0_apk was defined multiple times

Here is my layout code:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".MainActivity"
    tools:showIn="@layout/app_bar_main">

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="Bạn cảm thấy thế nào" />

        <Button
            android:id="@+id/checkSicknessBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="Kiểm tra"
            android:textColor="@android:color/holo_blue_light"
            android:textStyle="bold" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:background="#9ed7ec"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/linearLayout">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/content_margin"
            android:src="@drawable/baseline_access_alarm_white_48" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:text="Giờ uống thuốc sắp tới 15:30"
            android:textAlignment="center"
            android:textColor="#f29d15"
            android:textSize="20dp"
            android:textStyle="bold" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/baseline_keyboard_arrow_right_white_48" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="7dp"
        android:background="#9ed7ec"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/linearLayout2">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/content_margin"
            android:src="@drawable/baseline_event_white_48" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:text="Lịch hẹn sắp tới\n 29/2/2018 8:00"
            android:textAlignment="center"
            android:textColor="#f29d15"
            android:textSize="20dp"
            android:textStyle="bold" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/baseline_keyboard_arrow_right_white_48" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:orientation="vertical"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/linearLayout3">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/activity_vertical_margin"
            app:layout_constraintBottom_toTopOf="@+id/linearLayout9"
            app:layout_constraintTop_toTopOf="@+id/linearLayout9">

            <LinearLayout
                android:id="@+id/linearLayout11"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="53dp"
                android:layout_marginStart="53dp"
                android:layout_weight="1"
                android:background="#9ed7ec"
                android:gravity="center"
                android:orientation="vertical"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:src="@drawable/baseline_history_white_48" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="Lịch sử\n khám bệnh"
                    android:textSize="20dp"
                    android:textStyle="bold" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/linearLayout12"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginEnd="56dp"
                android:layout_marginRight="56dp"
                android:layout_weight="1"
                android:background="#9ed7ec"
                android:gravity="center"
                android:orientation="vertical"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:src="@drawable/baseline_insert_chart_outlined_white_48" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="Kết quả cận\n lâm sàng"
                    android:textSize="20dp"
                    android:textStyle="bold" />
            </LinearLayout>
        </android.support.constraint.ConstraintLayout>

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/activity_vertical_margin">

            <LinearLayout
                android:id="@+id/linearLayout13"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="53dp"
                android:layout_marginStart="53dp"
                android:layout_weight="1"
                android:background="#9ed7ec"
                android:gravity="center"
                android:orientation="vertical"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:src="@drawable/baseline_history_white_48" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="Lịch sử\n khám bệnh"
                    android:textSize="20dp"
                    android:textStyle="bold" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/linearLayout14"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginEnd="56dp"
                android:layout_marginRight="56dp"
                android:layout_weight="1"
                android:background="#9ed7ec"
                android:gravity="center"
                android:orientation="vertical"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:src="@drawable/baseline_insert_chart_outlined_white_48" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="Kết quả cận\n lâm sàng"
                    android:textSize="20dp"
                    android:textStyle="bold" />
            </LinearLayout>
        </android.support.constraint.ConstraintLayout>
    </LinearLayout>

</android.support.constraint.ConstraintLayout>

I first got an error code about "View constraint" in sub

<LinearLayout></LinearLayout>

and I fixed it by using infer constraint. I'm new to Android Layout and I'm trying to make a responsive layout with Constraint Layout. Please help me figure this out.

like image 724
Nguyen Hoang Vu Avatar asked Jun 04 '18 17:06

Nguyen Hoang Vu


2 Answers

You can try this by rebuilding the project.

Build-> Clean Project

Build-> Rebuild Project

like image 57
Mbuodile Obiosio Avatar answered Oct 31 '22 15:10

Mbuodile Obiosio


Please delete build and .gradle folder and then rebuild project.

like image 41
lalitkhandal Avatar answered Oct 31 '22 17:10

lalitkhandal