• 9
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Android AppBarLayout preview exception

Error using AppBarLayout, I tried the Clean Project and the Rebuild Project, but they didn't work.

There is no problem running the program. Why is that?

XML file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <com.google.android.material.appbar.AppBarLayout 
            android:layout_width="match_parent"
            android:layout_height="match_parent">

    </com.google.android.material.appbar.AppBarLayout>

</LinearLayout>

Gradle:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'android.arch.navigation:navigation-fragment:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    def nav_version = '1.0.0'
    implementation "android.arch.navigation:navigation-ui:$nav_version"
    implementation 'com.google.android.material:material:1.0.0'
}

Stack Trace:

java.lang.IllegalArgumentException: java.lang.ClassCastException@73c26ae
    at sun.reflect.GeneratedMethodAccessor274.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108)
    at android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:143)
    at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java)
    at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
    at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)
    at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)
    at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674)
    at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:637)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1069)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1088)
    at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
    at android.animation.StateListAnimator.start(StateListAnimator.java:188)
    at android.animation.StateListAnimator.setState(StateListAnimator.java:181)
    at android.view.View.drawableStateChanged(View.java:21105)
    at android.view.ViewGroup.drawableStateChanged(ViewGroup.java:7101)
    at android.view.View.refreshDrawableState(View.java:21160)
    at android.view.View.dispatchAttachedToWindow(View.java:18379)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3397)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:335)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:391)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:195)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:540)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$5(RenderTask.java:666)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

enter image description here enter image description here

Description is not sufficient to allow publishing?Description is not sufficient to allow publishing?

I have tried a number of projects with exactly the same code for the AppBarLayout in Linux (AS3.4 and AS3.5 - canary) and in Windows I tried it in AS3.3. It appears something about the AppBarLayout in the support library is not right. I used androidx. It seems something goes wrong after a few successful builds.

This is not a solution per se, but a possible workaround - you could avoid the AppBarLayout until the library is updated and AppBarLayout behaves well.

  • 1
Reply Report

You need to use like this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <com.google.android.material.appbar.AppBarLayout 
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

    </com.google.android.material.appbar.AppBarLayout>

</LinearLayout>

As you have added Material dependencies in gradle as com.google.android.material

  • 0
Reply Report

I had the same issue because I had upgraded my material library to 1.1.0-alpha10 after migration to androidX.

As a work around, I had to downgrade to 'com.google.android.material:material:1.0.0' then restart android studio. Hope it helps.

  • 0
Reply Report