2

My app fails to start because of Error inflating class ImageButton, Because of this the phone says "app has stopped" Etc. I am using firebase test lab to debug the problem

the Errors occur on samsung devices specifically A20, s7 Edge , s7(tested with firebase same problem)

I am new to android and have tried many solutions from google and SO none have worked sofar

Here is the error report on firebase

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartpractice.smartpracticesmartapp/com.smartpractice.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #117: Binary XML file line #117: Error inflating class ImageButton
     FATAL EXCEPTION: main
Process: com.smartpractice.smartpracticesmartapp, PID: 26921
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartpractice.smartpracticesmartapp/com.smartpractice.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #117: Binary XML file line #117: Error inflating class ImageButton
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
    at android.app.ActivityThread.access$1100(ActivityThread.java:221)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7224)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #117: Binary XML file line #117: Error inflating class ImageButton
    at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
    at com.smartpractice.myapplication.MainActivity.onCreate(MainActivity.java:14)
    at android.app.Activity.performCreate(Activity.java:6876)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
    ... 9 more
Caused by: android.view.InflateException: Binary XML file line #117: Error inflating class ImageButton
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
    ... 17 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070089
    at android.content.res.Resources.getValue(Resources.java:2558)
    at androidx.appcompat.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:331)
    at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
    at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
    at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:102)
    at androidx.appcompat.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:59)
    at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:79)
    at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:69)
    at androidx.appcompat.app.AppCompatViewInflater.createImageButton(AppCompatViewInflater.java:202)
    at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:122)
    at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
    at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:758)

Here is the XML

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="@+id/relativeLayout4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/ic_launcher_background"
    tools:context=".MainActivity">

    <com.google.android.flexbox.FlexboxLayout
        android:id="@+id/flexboxLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:alignContent="stretch"
        app:alignItems="stretch"
        app:flexWrap="wrap"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.863"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline7">


        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:fontFamily="@font/nunito"
            android:gravity="center_horizontal"
            android:text="@string/welcome_to_smartpractice"
            android:textSize="24sp"
            app:fontFamily="@font/nunito"
            app:layout_alignSelf="baseline"
            tools:layout_editor_absoluteY="100dp"
            tools:targetApi="jelly_bean" />

        <TextView
            android:id="@+id/textView7"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorPrimaryDark"
            android:gravity="center_horizontal|fill_vertical"
            android:text="@string/docsharesmart"
            android:textColor="@color/ic_launcher_background"
            app:layout_alignSelf="flex_end"
            tools:layout_editor_absoluteY="16dp" />

    </com.google.android.flexbox.FlexboxLayout>

    <com.google.android.flexbox.FlexboxLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="4dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="8dp"
        app:alignContent="center"
        app:alignItems="stretch"
        app:flexDirection="row"
        app:flexWrap="nowrap"
        app:justifyContent="space_between"
        app:layout_constraintBottom_toTopOf="@+id/guideline7"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:contentDescription="@string/logo1"
            app:layout_alignSelf="center"
            app:srcCompat="@drawable/smartpractice_logo_02"
            tools:layout_editor_absoluteX="0dp"
            tools:layout_editor_absoluteY="-46dp" />

        <ImageButton
            android:id="@+id/LoginScreen"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@null"
            android:contentDescription="@string/loginscreen"
            app:layout_alignSelf="center"
            app:layout_wrapBefore="false"
            app:srcCompat="@drawable/ic_more_vert_black_24dp"
            tools:layout_editor_absoluteX="248dp"
            tools:layout_editor_absoluteY="134dp" />


    </com.google.android.flexbox.FlexboxLayout>

    <com.google.android.flexbox.FlexboxLayout
        android:id="@+id/flexboxLayout2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        app:alignContent="stretch"
        app:alignItems="stretch"
        app:flexWrap="wrap"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/flexboxLayout"
        app:layout_constraintVertical_bias="0.146">

Here is line 117 from the error

        <ImageButton
            android:id="@+id/UploadButton"
            android:layout_width="300dp"
            android:layout_height="209dp"
            android:background="@android:color/transparent"
            app:layout_constraintTop_toBottomOf="@+id/flexboxLayout"
            app:srcCompat="@drawable/upload_files_upload"
            android:contentDescription="@string/todo" />


    </com.google.android.flexbox.FlexboxLayout>


    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_begin="185dp" />


</androidx.constraintlayout.widget.ConstraintLayout>
4

3 Answers 3

2

It means upload_files_upload is not found in drawble folder, well this can be a case, where your file may present in drawable-24 but not in drawble folder, in that case this problem still arise. The point is your file must be in all drawble folder.

Sign up to request clarification or add additional context in comments.

4 Comments

I just have one drawable folder, That is "Drawable" Must I add new drawable folders or what
@RubenMeiring No, that is not needed. Will try remove this line: app:srcCompat="@drawable/upload_files_upload" and build your project again. Let me know what happens
the button disapears it is an imagebutton and that removes the image
There might be a problem with your image, wil try loading different image in your ImageButton
1

The reason for your error is that the upload_files_upload is not in your drawable folder :

<ImageButton
            android:id="@+id/UploadButton"
            android:layout_width="300dp"
            android:layout_height="209dp"
            android:background="@android:color/transparent"
            app:layout_constraintTop_toBottomOf="@+id/flexboxLayout" 
            app:srcCompat="@drawable/upload_files_upload"// this line
            android:contentDescription="@string/todo" />

9 Comments

I only have the one drawable folder and the app works on several devices on my phone and several of my colleagues phones
Is your upload_files_upload vector drawable?
Yes it is, will that cause an issue??, It is in PNG format if that will make a diffrence
did you define defaultConfig { vectorDrawables.useSupportLibrary = true } in your build.gradle?
Yes, I have, the thing is the app works on some phones and some not, its very confusing
|
0

I have solved The Issue I changed app:srcCompat="@drawable/upload_files_upload"// to android:src="@drawable/upload_files_upload" So the problem was by app:srcCompat I changed it to Android:src and it works fine now

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.