0

The application currently has a Cardview, recyclerview, and its adapter. The cardView has and three images(one is a URL image and two are vector drawables) and two texts. I happen to face a crash everytime I launch the application. As it is my first time making an android app that requires Internet connection I suspect the problem to be around the dependencies/gradle/manifest.xml etc. The output is as so:

2021-06-17 03:09:45.376 8822-8822/? I/udio_downloade: Not late-enabling -Xcheck:jni (already on)
2021-06-17 03:09:45.415 8822-8822/? E/udio_downloade: Unknown bits set in runtime_flags: 0x8000
2021-06-17 03:09:45.416 8822-8822/? W/udio_downloade: Unexpected CPU variant for X86 using defaults: x86
2021-06-17 03:09:45.621 8822-8822/com.example.audio_downloader W/RenderThread: type=1400 audit(0.0:564): avc: denied { write } for name="property_service" dev="tmpfs" ino=8412 scontext=u:r:untrusted_app:s0:c146,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.example.audio_downloader
2021-06-17 03:09:45.635 8822-8855/com.example.audio_downloader D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
2021-06-17 03:09:45.636 8822-8855/com.example.audio_downloader W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
2021-06-17 03:09:45.642 8822-8855/com.example.audio_downloader D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2021-06-17 03:09:45.643 8822-8855/com.example.audio_downloader D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2021-06-17 03:09:45.645 8822-8855/com.example.audio_downloader D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2021-06-17 03:09:45.747 8822-8822/com.example.audio_downloader W/udio_downloade: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2021-06-17 03:09:45.747 8822-8822/com.example.audio_downloader W/udio_downloade: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2021-06-17 03:09:45.756 8822-8822/com.example.audio_downloader D/AndroidRuntime: Shutting down VM
2021-06-17 03:09:45.758 8822-8822/com.example.audio_downloader E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.audio_downloader, PID: 8822
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.audio_downloader/com.example.audio_downloader.MainActivity}: android.view.InflateException: Binary XML file line #2 in com.example.audio_downloader:layout/activity_main: Binary XML file line #2 in com.example.audio_downloader:layout/activity_main: Error inflating class layout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: android.view.InflateException: Binary XML file line #2 in com.example.audio_downloader:layout/activity_main: Binary XML file line #2 in com.example.audio_downloader:layout/activity_main: Error inflating class layout
     Caused by: android.view.InflateException: Binary XML file line #2 in com.example.audio_downloader:layout/activity_main: Error inflating class layout
     Caused by: java.lang.ClassNotFoundException: android.view.layout
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at android.view.LayoutInflater.createView(LayoutInflater.java:815)
        at android.view.LayoutInflater.createView(LayoutInflater.java:776)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:913)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:930)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:950)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:659)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at com.example.audio_downloader.MainActivity.onCreate(MainActivity.kt:19)
        at android.app.Activity.performCreate(Activity.java:7802)
        at android.app.Activity.performCreate(Activity.java:7791)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2021-06-17 03:09:45.758 8822-8822/com.example.audio_downloader E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.layout" on path: DexPathList[[zip file "/data/app/com.example.audio_downloader-c8ZlMIqksHRCoit9GGx70g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.audio_downloader-c8ZlMIqksHRCoit9GGx70g==/lib/x86, /system/lib, /system/product/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
            ... 31 more

The code analysis with Android Studio says there are no errors nor warnings in the code.

The dependencies and plugins are as follows:

    implementation 'androidx.core:core-ktx:1.5.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation "androidx.recyclerview:recyclerview:1.2.1"
    implementation "androidx.cardview:cardview:1.0.0"
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.code.gson:gson:2.8.6'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

As I use Picasso and the URL imaging I have added <uses-permission android:name="android.permission.INTERNET" /> to AndroidManifest.xml as well

I have tried using logcat but it seems like the application does not even enter the OnCreate() stage.

The XML file:

<?xml version="1.0" encoding="utf-8"?>
<layout 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">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:padding="4dp"
            tools:listitem="@layout/item_holder" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

I have tried enabling dataBinding and viewBinding. The kotlin-kapt plugin has also been tried. I've tried using viewBinding instead of kotlinx.synthetic.

KahngjoonK
  • 45
  • 7
  • 1
    Maybe include your `activity_main.xml` as that's what the error refers to? Seems like you might not have data binding enabled in your project and you've tried to use a `layout` tag. – Henry Twist Jun 16 '21 at 23:47
  • I Suggest you to check https://stackoverflow.com/questions/19874882/android-view-inflateexception-binary-xml-file-error-inflating-class-fragment – Parisa Baastani Jun 17 '21 at 05:57
  • paste your xml file – Sadegh J Jun 17 '21 at 07:35
  • @HenryTwist Yes I did use a layout tag without enabling data binding. I had the layout tag because I thought I was going to use data binding later on (haven't used it yet). – KahngjoonK Jun 17 '21 at 08:12
  • you are using parent layout as which is not correct, replace layout with , etc – waseem Jun 17 '21 at 09:42
  • I don't know about "not correct" @waseem. The `layout` tag is valid data binding syntax. Changing it to another tag would remove the data binding functionality. – Henry Twist Jun 17 '21 at 13:05

3 Answers3

0

May this help you by adding: android { //... dataBinding { enabled = true } }

And your question sounds like this question

Adarsh Raj
  • 325
  • 4
  • 17
  • I don't know if it is because I have added this line of code or I was fiddling with something else, but now I the application goes through onCreate() and the onCreateViewholder() of my RecylcerViewAdapter is exectued. Though I still have the previous problem. – KahngjoonK Jun 17 '21 at 08:36
0

I'm sorry for all those who have invested time on trying to solve my issue. It was that I had a TODO stuck in my adapter code. (I came from python and having TODO's in the middle of the code causes no problem as it is written as a comment and I thought it was the same...) That TODO function was jamming the rest of the processes.

KahngjoonK
  • 45
  • 7
-1

Please check if is not a duplicate of this post? based on your error stack trace seems very similar.

Android binary layout inflate exception : ClassNotFoundException: Didn't find class "android.view.layout" on path:

Catluc
  • 1,775
  • 17
  • 25
  • `android { //... dataBinding { enabled = true } }` nor `buildFeatures { dataBinding = true }` nor `apply plugin: 'kotlin-kapt'` is working – KahngjoonK Jun 17 '21 at 08:45
  • This doesn't answer the question @Catluc, if you've found a post that you think is a duplicate then you should flag it appropriately. Otherwise link-only answers are generally frowned upon here for a great many reasons, this post has great information on why: https://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers – Henry Twist Jun 17 '21 at 13:08