Error inflating class ja.burhanrashid52.photoeditor.PhotoEditorView

by Yusril Maulidan Raji   Last Updated October 09, 2019 14:26 PM - source

Currently, I am developing an android app using PhotoEditor library. I have followed the Getting Started and Setting up the View sections as explained on the page. However, somehow, I cannot inflate the UI XML that contains PhotoEditorView. Here is my code:

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent">

        <ja.burhanrashid52.photoeditor.PhotoEditorView
            android:id="@+id/photoEditorView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </ja.burhanrashid52.photoeditor.PhotoEditorView>

</RelativeLayout>

Fragment:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    try {
        final View view = inflater.inflate(R.layout.app_fragment_edit_picture, container, false);
    }
    catch (Exception e) {
        LogHelper.LogError("TEST");
    }

    return null;
}

I put the try-catch and return null there only for testing.

Error:

Binary XML file line #9: Binary XML file line #9: Error inflating class ja.burhanrashid52.photoeditor.PhotoEditorView

Does anyone have a clue?

As requested, here is the full stack trace:

android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class ja.burhanrashid52.photoeditor.PhotoEditorView at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at com.mobileop.app.gui.fragments.EditPictureFragment.onCreateView(EditPictureFragment.java:54) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273) at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229) at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2466) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1483) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5551) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class ja.burhanrashid52.photoeditor.PhotoEditorView at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) ... 30 more Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at android.view.LayoutInflater.createView(LayoutInflater.java:619) ... 35 more Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lja/burhanrashid52/photoeditor/R$styleable; at ja.burhanrashid52.photoeditor.PhotoEditorView.init(PhotoEditorView.java:72) at ja.burhanrashid52.photoeditor.PhotoEditorView.(PhotoEditorView.java:48) ... 37 more Caused by: java.lang.ClassNotFoundException: Didn't find class "ja.burhanrashid52.photoeditor.R$styleable" on path: DexPathList[[zip file "/data/app/com.mobileop-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mobileop-1/lib/arm, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) ... 39 more Suppressed: java.lang.ClassNotFoundException: ja.burhanrashid52.photoeditor.R$styleable at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 40 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available



Answers 1


You have to return a View, you are returning null in the function.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle 
savedInstanceState) {
// Inflate the layout for this fragment
try {
    final View view = inflater.inflate(R.layout.app_fragment_edit_picture, container, 
false);
}
catch (Exception e) {
    LogHelper.LogError("TEST");
}

return view;
}
Adnan Temur
Adnan Temur
October 09, 2019 14:25 PM

Related Questions


How to progress bar fill from down to up in android

Updated April 04, 2017 14:26 PM

How do I make a ChipGroup to act like a radioButton?

Updated October 05, 2019 06:26 AM

Can we make one Layout type for all screen size

Updated November 28, 2017 04:26 AM

Newsfeed from LayoutInflater doesn't work

Updated November 03, 2017 13:26 PM