[Solved] My app is not working on Marshmallow and below but min sdk is 21. How to resolve?


You have given constraints to map Imagebutton, textView6 TextView and club ImageButton with respect to calender id but as i can see in your activity_main.xml file there is no view having calender id. May be you have it earlier but after that you have changed it to cal id. so, you have to refer your view constraints with respect to cal instead of calender id. Because of wrong id you are getting inflating error.

I have modified your activity_main.xml as below. you can just copy and paste it in your code.

edited activity_main.xml

    <?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="wrap_content"
    android:layout_height="match_parent"
    android:background="#ffffff"
    tools:context=".MainActivity"
    tools:layout_editor_absoluteY="25dp"
    tools:layout_width="match_parent">


    <ImageButton
        android:id="@+id/cgpa"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:background="#ffffff"
        android:onClick="clickcgpa"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/cal"
        android:contentDescription="@string/todo4" />

    <ImageButton
        android:id="@+id/cal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true"
        android:background="#ffffff"
        android:onClick="clickcal"
        app:layout_constraintEnd_toStartOf="@+id/club"
        app:layout_constraintStart_toEndOf="@+id/map"
        app:layout_constraintTop_toTopOf="@+id/club"
        app:srcCompat="@drawable/calender"
        android:contentDescription="@string/todo3" />

    <ImageButton
        android:id="@+id/map"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignTop="@+id/cgpa"
        android:layout_marginStart="3dp"
        android:background="#ffffff"
        android:onClick="clickmap"
        app:layout_constraintEnd_toStartOf="@+id/cal"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/cal"
        app:srcCompat="@drawable/marker"
        android:contentDescription="@string/todo1" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/cgpa"
        android:layout_marginEnd="9dp"
        android:text="@string/cgpa_calculator"
        android:textAlignment="center"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/cgpa"
        app:layout_constraintTop_toBottomOf="@+id/cgpa" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginStart="16dp"
        android:text="@string/campus_map"
        android:textAlignment="center"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="@+id/textView6"
        app:layout_constraintStart_toStartOf="@+id/map"
        app:layout_constraintTop_toBottomOf="@+id/map" />

    <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentTop="true"
        android:layout_marginEnd="33dp"
        android:gravity="center_vertical"
        android:text="@string/Main"
        android:textAlignment="center"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/cal"
        app:layout_constraintTop_toBottomOf="@+id/cal" />

    <TextView
        android:id="@+id/textView7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="18dp"
        android:fontFamily="monospace"
        android:text="@string/coming_soon"
        android:textAppearance="@style/TextAppearance.AppCompat.Body2"
        android:textColor="#777777"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView4" />

    <ImageButton
        android:id="@+id/club"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="234dp"
        android:background="#ffffff"
        android:onClick="clickclub"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/cal"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/people2"
        android:contentDescription="@string/todo2" />

    <TextView
        android:id="@+id/textView8"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/club"
        android:textAlignment="center"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/club"
        app:layout_constraintStart_toStartOf="@+id/club"
        app:layout_constraintTop_toBottomOf="@+id/club" />

</android.support.constraint.ConstraintLayout>

And in future if you want to change any views id then i suggest you to change it from design section because it will ask you a option to change id at all places where you have used it. So, you don’t need to update it manually at every place.

UPDATE

As i can see in your project code(Received in private chat) there is some images only in drawable-v24. So, this images are only comfortable with some versions as said here. So, you have to put your images in drawable folder also to make compatible your app in all the versions.

As i can see there is two images cal.png and people2.png in only drawable-v24 and not in drawable folder. so, simple copy and paste them into drawable folder and all will be ok. You can run your project on every devices having versions between your minsdk and targetsdk version.

0

solved My app is not working on Marshmallow and below but min sdk is 21. How to resolve?