Not able to set another image below first image in linear layout - android

I'm working on some project and i use linear layout and set image and text in it. after ending first linear layout i want another linear layout and set image. But i'm setting image my app keep on crashing.
This is Code:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".guidance_new"
android:id="#+id/layout"
android:background="#drawable/bg_animation"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="#+id/hanging_lamp"
android:src="#drawable/bulb1"/>
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="180dp"
android:orientation="vertical"
>
<TextView
android:layout_width="150dp"
android:layout_height="70dp"
android:text="100W Bulb"
android:textColor="#000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginLeft="180dp"
android:id="#+id/textView1"/>
<TextView
android:layout_width="150dp"
android:layout_height="80dp"
android:text="Price:100/. Voltage:220V-240V ."
android:textColor="#a9a9a9"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginLeft="180dp"
android:id="#+id/textView2"/>
/////// layout is set here
</LinearLayout>
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="#+id/chandlier"
android:src="#drawable/chandelier"
android:layout_below="#id/linear1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_below="#id/linear1">
<TextView
android:layout_width="150dp"
android:layout_height="70dp"
android:text="Chandlier"
android:textColor="#000"
android:textStyle="bold"
android:layout_marginLeft="180dp"
android:textSize="20sp"/>
</LinearLayout>
</RelativeLayout>
And this is mainlog:
06-09 18:26:34.348 23904-23904/com.example.animation E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.animation, PID: 23904
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.animation/com.example.animation.guidance_new}: android.view.InflateException: Binary XML file line #52: Binary XML file line #52: Error inflating class ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2484)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: android.view.InflateException: Binary XML file line #52: Binary XML file line #52: Error inflating class ImageView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.animation.guidance_new.onCreate(guidance_new.java:20)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544) 
at android.app.ActivityThread.access$900(ActivityThread.java:150) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:168) 
at android.app.ActivityThread.main(ActivityThread.java:5845) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 
Caused by: android.view.InflateException: Binary XML file line #52: Error inflating class ImageView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
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)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.example.animation.guidance_new.onCreate(guidance_new.java:20) 
at android.app.Activity.performCreate(Activity.java:6248) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544) 
at android.app.ActivityThread.access$900(ActivityThread.java:150) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:168) 
at android.app.ActivityThread.main(ActivityThread.java:5845) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 
Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.animation:drawable/chandelier" (7f060064) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060064 a=-1 r=0x7f060064}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2617)
at android.content.res.Resources.loadDrawable(Resources.java:2555)
at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
at android.widget.ImageView.<init>(ImageView.java:152)
at android.widget.ImageView.<init>(ImageView.java:140)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
at android.support.v7.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:182)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746)
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) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.example.animation.guidance_new.onCreate(guidance_new.java:20) 
at android.app.Activity.performCreate(Activity.java:6248) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544) 
at android.app.ActivityThread.access$900(ActivityThread.java:150) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:168) 
at android.app.ActivityThread.main(ActivityThread.java:5845) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 
06-09 18:26:34.357 23904-23927/com.example.animation V/FA: Connection attempt already in progress

Resource that you are trying to display in ImageView (chandelier) is invalid.
You can read in your log that: Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.animation:drawable/chandelier" (7f060064) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060064 a=-1 r=0x7f060064} Check if path to the file is correct and try to display other image.

Try this xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:layout_height="match_parent"
tools:context=".guidance_new"
android:id="#+id/layout"
android:background="#drawable/bg_animation"
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="#+id/hanging_lamp"
android:src="#drawable/bulb1"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="70dp"
android:text="100W Bulb"
android:textColor="#000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginLeft="30dp"
android:id="#+id/textView1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="80dp"
android:text="Price:100/. Voltage:220V-240V ."
android:textColor="#a9a9a9"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginLeft="30dp"
android:id="#+id/textView2"/>
</LinearLayout>
/////// layout is set here
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/chandelier"
android:orientation="horizontal"
android:layout_marginTop="30dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="#+id/chandlier"
android:src="#drawable/bulb1"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="70dp"
android:textColor="#000"
android:textStyle="bold"
android:text="Chandlier"
android:textSize="20sp"
android:layout_marginLeft="30dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Related

(< API 24) NavigationView Error (inflating class) (works in API24+)

So I have a problem with devices that are below API 24. My code works in API 24+
I always get an error when I try to set the layout of my NavDrawer:
setContentView(R.layout.activity_nav_drawer);
Layout File:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_nav_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_nav_drawer"
app:itemIconTint="#color/colorPrimary"
app:menu="#menu/activity_nav_drawer_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
MANIFEST (Theme):
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:networkSecurityConfig="#xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:roundIcon="#mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="#style/AppTheme">
Changed the AppThme no it gives me this error from the Fragment.
Again its loading the layout and gives me this error:
The line where the error occurs is a Webview
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.streamdev.aiostreamer/com.streamdev.aiostreamer.NavDrawer}: android.view.InflateException: Binary XML file line #29: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at com.streamdev.aiostreamer.ui.HQPFragment.onCreateView(HQPFragment.java:69)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2624)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1236)
at android.app.Activity.performStart(Activity.java:6006)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at com.streamdev.aiostreamer.ui.HQPFragment.onCreateView(HQPFragment.java:69) 
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600) 
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881) 
at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100) 
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874) 
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830) 
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) 
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663) 
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613) 
at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2624) 
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904) 
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) 
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) 
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659) 
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613) 
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246) 
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542) 
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201) 
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1236) 
at android.app.Activity.performStart(Activity.java:6006) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040003
at android.content.res.Resources.getText(Resources.java:299)
at android.conten
My activity main.xml (all fragments uses this one):
<?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/main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/scrollView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#202020"
>
<LinearLayout
android:id="#+id/relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#202020"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<WebView
android:id="#+id/adview"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#202020"/>
<com.streamdev.aiostreamer.ui.ExpandableHeightGridView
android:id="#+id/customgrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/os_texts"
android:background="#202020"
android:gravity="center"
android:horizontalSpacing="2dp"
android:listSelector="#00000000"
android:numColumns="2"
android:paddingTop="0dp"
android:verticalSpacing="10dp">
</com.streamdev.aiostreamer.ui.ExpandableHeightGridView>
<WebView
android:id="#+id/adview2"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="60dp"
android:layout_alignParentBottom="true"
android:layout_marginTop="0dp"
android:paddingTop="0dp"
android:background="#202020"/>
</LinearLayout>
</ScrollView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#color/colorPrimary"
app:itemIconTint="#FFFFFF"
app:itemTextColor="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:menu="#menu/bottom_nav_menu" />
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<AutoCompleteTextView
android:id="#+id/searchtext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:completionThreshold="1"
android:hint="Search..."
android:maxLines="1"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
/>
<Button
android:id="#+id/searchbutton"
style="#style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Your first line of the error showing that below view is the reason of the issue.
<com.streamdev.aiostreamer.ui.ExpandableHeightGridView
android:id="#+id/customgrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/os_texts"
android:background="#202020"
android:gravity="center"
android:horizontalSpacing="2dp"
android:listSelector="#00000000"
android:numColumns="2"
android:paddingTop="0dp"
android:verticalSpacing="10dp">
</com.streamdev.aiostreamer.ui.ExpandableHeightGridView>

android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class Button

here im my error sample and my .xml
10-22 15:47:02.959 18003-18003/tips.admin.tipsscore.rewards E/AndroidRuntime: FATAL EXCEPTION: main
Process: tips.admin.tipsscore.rewards, PID: 18003
java.lang.RuntimeException: Unable to start activity ComponentInfo{tips.admin.tipsscore.rewards/tips.admin.tipsscore.rewards.MainActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class Button
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class Button
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at tips.admin.tipsscore.rewards.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
XML:
<Button
android:id="#+id/back"
android:layout_width="110dp"
android:layout_height="55dp"
android:background="#drawable/back"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="12dp" />
<Button
android:id="#+id/rewards"
android:layout_width="124dp"
android:layout_height="53dp"
android:background="#drawable/reward_btn"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="34dp"
tools:layout_editor_absoluteY="82dp" />
<ImageView
android:id="#+id/imageView"
android:layout_width="348dp"
android:layout_height="428dp"
app:srcCompat="#drawable/bg_content"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="67dp" />
<Button
android:id="#+id/invite"
android:layout_width="317dp"
android:layout_height="79dp"
android:background="#drawable/reward_btn"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="34dp"
tools:layout_editor_absoluteY="290dp" />
<Button
android:id="#+id/plus"
android:layout_width="39dp"
android:layout_height="36dp"
android:background="#drawable/btnplus"
android:paddingLeft="40dp"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="325dp"
tools:layout_editor_absoluteY="16dp" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="210dp"
android:layout_height="74dp"
tools:ignore="MissingConstraints"
app:srcCompat="#drawable/barkoin"
tools:layout_editor_absoluteX="154dp"
tools:layout_editor_absoluteY="0dp" />
<TextView
android:id="#+id/coins"
android:layout_width="90dp"
android:layout_height="25dp"
android:text="000000"
android:textColor="#0ede50"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="229dp"
tools:layout_editor_absoluteY="25dp" />
<TextView
android:id="#+id/availabele"
android:layout_width="205dp"
android:layout_height="75dp"
android:text="YOU HAVE 20 AVAILILABE GIFTS "
android:textColor="#0ede50"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="163dp"
tools:layout_editor_absoluteY="67dp" />
<Button
android:id="#+id/redeam"
android:layout_width="317dp"
android:layout_height="79dp"
android:background="#drawable/reward_btn"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="34dp"
tools:layout_editor_absoluteY="396dp" />
<TextView
android:id="#+id/refeer"
android:layout_width="267dp"
android:layout_height="99dp"
android:text="DID YOU KNOW INVITING OR REFERRING YOU FRIENDS CAN EARN YOU MORE COINS? INVITE YOUR FRIENDS FOR MORE COINS "
android:textColor="#0ede50"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="58dp"
tools:layout_editor_absoluteY="187dp" />

How do I resolve this InflateException - after clicking a button?

This is the error that occurs when I click a button:
09-15 01:09:08.934 32386-32386/com.example.ajalandoni.chemistryworld E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ajalandoni.chemistryworld, PID: 32386
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ajalandoni.chemistryworld/sarveshchavan777.triviaquiz.MainGameActivity}: android.view.InflateException: Binary XML file line #105: Binary XML file line #105: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2781)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #105: Binary XML file line #105: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #105: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at sarveshchavan777.triviaquiz.MainGameActivity.onCreate(MainGameActivity.java:36)
at android.app.Activity.performCreate(Activity.java:7013)
at android.app.Activity.performCreate(Activity.java:7004)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2734)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
at android.content.res.TypedArray.getColor(TypedArray.java:473)
at info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)
at info.hoang8f.widget.FButton.<init>(FButton.java:52)
at java.lang.reflect.Constructor.newInstance0(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:334) 
at android.view.LayoutInflater.createView(LayoutInflater.java:647) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at sarveshchavan777.triviaquiz.MainGameActivity.onCreate(MainGameActivity.java:36) 
at android.app.Activity.performCreate(Activity.java:7013) 
at android.app.Activity.performCreate(Activity.java:7004) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2734) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6518) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
This my activity_game_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fbutton="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/backgroundColor"
android:orientation="vertical"
tools:context="sarveshchavan777.triviaquiz.MainGameActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#color/lightGreen"
android:minHeight="?actionBarSize">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="0dp">
<ImageView
android:id="#+id/coinImage"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/coin" />
<TextView
android:id="#+id/coinText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text=""
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:gravity="center"
android:textSize="20sp"
android:layout_toRightOf="#id/coinImage"
android:layout_toEndOf="#id/coinImage" />
<TextView
android:id="#+id/triviaQuizText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/app_name"
android:textColor="#color/white"
android:textSize="25sp"
android:layout_toLeftOf="#+id/timeText"
android:layout_toRightOf="#+id/coinText"
android:layout_toStartOf="#+id/timeText"
android:layout_toEndOf="#+id/coinText" />
<TextView
android:id="#+id/timeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:paddingLeft="10dp"
android:gravity="center"
android:paddingRight="10dp"
android:text="#string/time"
android:textSize="20sp" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<View
android:layout_width="match_parent"
android:layout_height="10dp"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".5"
android:background="#color/white"
android:orientation="vertical">
<TextView
android:id="#+id/triviaQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="#string/question"
android:textColor="#color/grey"
android:textSize="18sp" />
<TextView
android:id="#+id/resultText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text=""
android:textColor="#color/green"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<info.hoang8f.widget.FButton
android:id="#+id/buttonA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:onClick="buttonA"
android:text=""
android:textColor="#color/grey"
fbutton:buttonColor="#color/white"
fbutton:cornerRadius="10dp"
fbutton:shadowColor="#color/grey" />
<info.hoang8f.widget.FButton
android:id="#+id/buttonB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:onClick="buttonB"
android:text=""
android:textColor="#color/grey"
fbutton:buttonColor="#color/white"
fbutton:cornerRadius="10dp"
fbutton:shadowColor="#color/grey" />
<info.hoang8f.widget.FButton
android:id="#+id/buttonC"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:onClick="buttonC"
android:text=""
android:textColor="#color/grey"
fbutton:buttonColor="#color/white"
fbutton:cornerRadius="10dp"
fbutton:shadowColor="#color/grey" />
<info.hoang8f.widget.FButton
android:id="#+id/buttonD"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:onClick="buttonD"
android:text=""
android:textColor="#color/grey"
fbutton:buttonColor="#color/white"
fbutton:cornerRadius="10dp"
fbutton:shadowColor="#color/grey" />
</LinearLayout>
</LinearLayout>
What could be the possible cause of this problem?
I already tried this solution, but this doesn't work for me.
Change your dependency with this
compile 'com.github.jd-alexander:android-flat-button:v1.1'
use this library it will fix your problem. The library you are using has some issue check this library.
Also add maven { url "https://jitpack.io" } in build.gradle (Project Level) in repositories block your code will look like this :
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
Well I think the problem is with the android gradle plugin version. Try changing it to 2.3.3 in File -> Project Structure -> Project.

I encountered this error in android studio while learning it

I encountered this error in android studio while learning it:
08-20 11:56:52.192 9815-9815/com.example.android.courtcountee1 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.courtcountee1, PID: 9815
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.courtcountee1/com.example.android.courtcountee1.MainActivity}: android.view.InflateException: Binary XML file line #66: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
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 #66: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.android.courtcountee1.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415) 
at android.app.ActivityThread.access$1100(ActivityThread.java:229) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:7325) 
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: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
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)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at com.example.android.courtcountee1.MainActivity.onCreate(MainActivity.java:15) 
at android.app.Activity.performCreate(Activity.java:6904) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415) 
at android.app.ActivityThread.access$1100(ActivityThread.java:229) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:7325) 
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) 
The XML
i THINK THE VIEW TAG IS CAUSING THE PROBLEM AS REMOVING IT RESOLVED THIS
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:layout_weight="1"
android:orientation="vertical"
tools:context="com.example.android.courtcounter.MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="Team A" />
<TextView
android:id="#+id/team_a_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:fontFamily="sans-serif-light"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="0"
android:textColor="#000000"
android:textSize="56dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="threePoints"
android:text="+3 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="twoPoints"
android:text="+2 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="freeThrow"
android:text="Free Throw" />
</LinearLayout>
<!--<view
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:background="#android:color/darker_gray">
</view>-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="24dp"
android:layout_weight="1"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="Team B"
android:textColor="#616161"
android:textSize="14sp" />
<TextView
android:id="#+id/team_b_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:fontFamily="sans-serif-light"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="0"
android:textColor="#000000"
android:textSize="56dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="threePointsB"
android:text="+3 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="twoPointsB"
android:text="+2 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="freeThrowB"
android:text="Free Throw" />
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="32dp"
android:onClick="reset"
android:text="RESET" />
</RelativeLayout>
View tag must start with the capital letter, like this:
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:background="#android:color/darker_gray">
</View>
In fact,Every xml View tag will through the LayoutInflater class construct a real View class. About LayoutInflater, It will combine the xml tag with the View class in package android.view.、android.widget、android.webkit、android.app. About you use the view tag, you should use like this.
<view
android:id="#+id/test"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
class="androidx.constraintlayout.utils.widget.ImageFilterView"
android:background="#color/colorAccent"
/>
you must appoint the target class. because the LayoutInflater tell us should do.
View createViewFromTag(View parent, String name, Context context, AttributeSet attrs,
boolean ignoreThemeAttr) {
if (name.equals("view")) {
name = attrs.getAttributeValue(null, "class");
}
// Apply a theme wrapper, if allowed and one is specified.
if (!ignoreThemeAttr) {
final TypedArray ta = context.obtainStyledAttributes(attrs, ATTRS_THEME);
final int themeResId = ta.getResourceId(0, 0);
if (themeResId != 0) {
context = new ContextThemeWrapper(context, themeResId);
}
ta.recycle();
}
if (name.equals(TAG_1995)) {
// Let's party like it's 1995!
return new BlinkLayout(context, attrs);
}
...
because you not appoint the class.It can not find the real class about it,So It cause the exception.

Android MaterialSpinner (Github) causes Inflate Exception

I am using a MaterialSpinner library from github(https://github.com/ganfra/MaterialSpinner) in my application.When I try to run in genymotion emulator, it works ok.But when I try to run it on my smartphone it shoes InflateException for the MaterialSpinner.
Error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jobinsabu.destination/com.example.jobinsabu.destination.MainActivity}: android.view.InflateException: Binary XML file line #100: Error inflating class fr.ganfra.materialspinner.MaterialSpinner
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2252)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2306)
at android.app.ActivityThread.access$700(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5302)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #100: Error inflating class fr.ganfra.materialspinner.MaterialSpinner
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.example.jobinsabu.destination.MainActivity.onCreate(MainActivity.java:102)
at android.app.Activity.performCreate(Activity.java:5326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2306) 
at android.app.ActivityThread.access$700(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:176) 
at android.app.ActivityThread.main(ActivityThread.java:5302) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:593)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
at com.example.jobinsabu.destination.MainActivity.onCreate(MainActivity.java:102) 
at android.app.Activity.performCreate(Activity.java:5326) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2306) 
at android.app.ActivityThread.access$700(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:176) 
at android.app.ActivityThread.main(ActivityThread.java:5302) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.NoClassDefFoundError: fr.ganfra.materialspinner.R$attr
at fr.ganfra.materialspinner.MaterialSpinner.initAttributes(MaterialSpinner.java:149)
at fr.ganfra.materialspinner.MaterialSpinner.init(MaterialSpinner.java:135)
at fr.ganfra.materialspinner.MaterialSpinner.<init>(MaterialSpinner.java:117)
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
at android.view.LayoutInflater.createView(LayoutInflater.java:593) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
at com.example.jobinsabu.destination.MainActivity.onCreate(MainActivity.java:102) 
at android.app.Activity.performCreate(Activity.java:5326) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2306) 
at android.app.ActivityThread.access$700(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:176) 
at android.app.ActivityThread.main(ActivityThread.java:5302) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
at dalvik.system.NativeStart.main(Native Method) 
activity_main.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:id="#+id/relative"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/bg7"
>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#android:color/transparent"
android:theme="#style/AppTheme"
android:titleTextColor="#ffffff"
app:titleTextColor="#ffffff" />
<com.miguelcatalan.materialsearchview.MaterialSearchView
android:id="#+id/search_view"
style="#style/MaterialSearchView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:id="#+id/rehold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/search_view"
android:layout_centerHorizontal="true"
android:visibility="invisible"
>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
>
</android.support.v7.widget.RecyclerView>
<Button
android:id="#+id/done"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="Done"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Destination"
android:textColor="#fff"
android:textSize="25sp"
android:textStyle="italic"
android:layout_marginTop="135dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:background="#drawable/touricon"
android:layout_alignBottom="#+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="50dp" />
<RelativeLayout
android:id="#+id/relative2"
android:layout_width="match_parent"
android:layout_height="140dp"
android:gravity="center"
android:layout_alignTop="#+id/rehold"
android:layout_below="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="120dp">
<ImageView
android:id="#+id/image1"
android:layout_width="30dp"
android:layout_height="35dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="34dp"
android:layout_marginStart="34dp"
android:background="#drawable/marker"></ImageView>
<fr.ganfra.materialspinner.MaterialSpinner
android:id="#+id/spinner1"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:gravity="center"
app:ms_alignLabels="false"
app:ms_arrowColor="#color/arrow"
app:ms_arrowSize="23dp"
app:ms_hintColor="#color/hint"
app:ms_multiline="true"
app:ms_thickness="0.0dp"
app:popupTheme="#android:color/transparent"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/image1"
android:layout_toEndOf="#+id/image1" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
spinner_item.xml(layout of spinner items):
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="154dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:background="#drawable/spinner_style"
>
<TextView
android:id="#+id/item1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="Aizwal"
android:textColor="#212121"
android:textSize="25sp"
android:layout_gravity="left|center_vertical" />
</FrameLayout>
MainActivity.java:
public class MainActivity extends AppCompatActivity{
public MaterialSpinner spinner;ArrayList l;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner=(MaterialSpinner) findViewById(R.id.spinner1);
l = new ArrayList();
l.add("NewDelhi");
l.add("Mumbai");
l.add("Chennai");
l.add("Bangalore");
arrayAdapter=new ArrayAdapter<String>(this,R.layout.spinner_item,R.id.item1,l);
spinner.setAdapter(arrayAdapter);}}
Replace this
arrayAdapter=new ArrayAdapter<String>(this,R.layout.spinner_item,R.id.item1,l);
With
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, l);

Categories

Resources