Without editing Manifest
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and values\styles
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
I get mistake like this
02-09 20:42:47.567 24389-24389/? E/AndroidRuntime: FATAL EXCEPTION:
main
Process: com.example.golendukhin.settingsSwitcher, PID: 24389
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.golendukhin.settingsSwitcher/com.example.golendukhin.settingsSwitcher.MainActivity}:
android.view.InflateException: Binary XML file line #2: Binary XML
file line #2: Error inflating class
android.support.design.widget.CoordinatorLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2581)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML
file line #2: Error inflating class
android.support.design.widget.CoordinatorLayout
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:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.golendukhin.settingsSwitcher.MainActivity.onCreate(MainActivity.java:61)
at android.app.Activity.performCreate(Activity.java:6280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
Caused by: android.view.InflateException: Binary XML file line #2: Error
inflating class android.support.design.widget.CoordinatorLayout
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.inflate(LayoutInflater.java:492)
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:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.golendukhin.settingsSwitcher.MainActivity.onCreate(MainActivity.java:61)
at android.app.Activity.performCreate(Activity.java:6280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
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:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.golendukhin.settingsSwitcher.MainActivity.onCreate(MainActivity.java:61)
at android.app.Activity.performCreate(Activity.java:6280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat
theme (or descendant) with the design library.
at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:36)
at android.support.design.widget.CoordinatorLayout.(CoordinatorLayout.java:192)
at android.support.design.widget.CoordinatorLayout.(CoordinatorLayout.java:186)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
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:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.golendukhin.settingsSwitcher.MainActivity.onCreate(MainActivity.java:61)
at android.app.Activity.performCreate(Activity.java:6280)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
The question is - what kind of mistake I made.
Creating new "Hello World!" project with same manifest and style files works fine. In both projects Main Activity extends AppCompatActivity.
Totally stuck trying to realize what happend with project.
Googling provided me with idea to change Theme in manifest.
I did so and replaced
android:theme="#style/AppTheme.NoActionBar">
with
android:theme="#style/Theme.AppCompat">
Theme became dark and styling it in "Style" had no effect.
I even removed base applicaion theme - no effect. So, this is not a proper way.
Need any help, I don't even know what to do next.
Solution is preaty unobvious.
I have removed <!--android:theme="#style/Theme.AppCompat">--> from "activity" node in Manifest, renamed <style name="AppTheme"parent="Theme.AppCompat.Light.DarkActionBar"> to <style name="MainTheme" parent="Theme.AppCompat.Light.DarkActionBar"> and applyed my renamed MainTheme to all application in "application" node in Manifest android:theme="#style/MainTheme">
App now works. Probably "AppTheme" is predefined somehow in android.
Thanks to lalit jadhav for an advised tutotial. He really helped.
Manifest
...
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/MainTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<!--android:theme="#style/Theme.AppCompat">-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
styles.xml
<!-- Base application theme. -->
<style name="MainTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<!--<item name="colorPrimaryDark">#color/colorPrimary</item>-->
<!--<item name="colorAccent">#color/colorPrimary</item>-->
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Related
I'm using approach with themes to add cornered edges, but bottom sheet crashes app on show.
Here's BottomSheet itself
class MyBottomSheet : BottomSheetDialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(DialogFragment.STYLE_NORMAL, R.style.ThemeOverlay_App_BottomSheetDialog)
}
Here it's style
<style name="ThemeOverlay.App.BottomSheetDialog" parent="ThemeOverlay.MaterialComponents.Dialog">
<item name="bottomSheetStyle">#style/CustomBottomSheet</item>
</style>
<style name="CustomBottomSheet" parent="Widget.MaterialComponents.BottomSheet">
<item name="shapeAppearanceOverlay">#style/CustomShapeAppearanceOverlay.MaterialComponents.BottomSheet</item>
</style>
<style name="CustomShapeAppearanceOverlay.MaterialComponents.BottomSheet" parent="">
<item name="cornerSizeTopRight">16dp</item>
<item name="cornerSizeTopLeft">16dp</item>
<item name="cornerSizeBottomRight">0dp</item>
<item name="cornerSizeBottomLeft">0dp</item>
</style>
I experience issues with that part Widget.MaterialComponents.BottomSheet, when I add any style that extends that theme to the <item name="bottomSheetStyle">#style/CustomBottomSheet</item> app crashes with error log:
android.view.InflateException: Binary XML file line #41: Could not inflate Behavior subclass com.google.android.material.bottomsheet.BottomSheetBehavior
Caused by: java.lang.RuntimeException: Could not inflate Behavior subclass com.google.android.material.bottomsheet.BottomSheetBehavior
at androidx.coordinatorlayout.widget.CoordinatorLayout.parseBehavior(CoordinatorLayout.java:649)
at androidx.coordinatorlayout.widget.CoordinatorLayout$LayoutParams.<init>(CoordinatorLayout.java:2896)
at androidx.coordinatorlayout.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:1740)
at androidx.coordinatorlayout.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:112)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
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.view.View.inflate(View.java:24354)
at com.google.android.material.bottomsheet.BottomSheetDialog.ensureContainerAndBehavior(BottomSheetDialog.java:188)
at com.google.android.material.bottomsheet.BottomSheetDialog.wrapInBottomSheet(BottomSheetDialog.java:200)
at com.google.android.material.bottomsheet.BottomSheetDialog.setContentView(BottomSheetDialog.java:93)
at androidx.fragment.app.DialogFragment$4.onChanged(DialogFragment.java:155)
at androidx.fragment.app.DialogFragment$4.onChanged(DialogFragment.java:140)
at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2961)
at androidx.fragment.app.DialogFragment.performCreateView(DialogFragment.java:486)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:515)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2088)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at androidx.coordinatorlayout.widget.CoordinatorLayout.parseBehavior(CoordinatorLayout.java:647)
at androidx.coordinatorlayout.widget.CoordinatorLayout$LayoutParams.<init>(CoordinatorLayout.java:2896)
at androidx.coordinatorlayout.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:1740)
at androidx.coordinatorlayout.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:112)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
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.view.View.inflate(View.java:24354)
at com.google.android.material.bottomsheet.BottomSheetDialog.ensureContainerAndBehavior(BottomSheetDialog.java:188)
at com.google.android.material.bottomsheet.BottomSheetDialog.wrapInBottomSheet(BottomSheetDialog.java:200)
at com.google.android.material.bottomsheet.BottomSheetDialog.setContentView(BottomSheetDialog.java:93)
at androidx.fragment.app.DialogFragment$4.onChanged(DialogFragment.java:155)
at androidx.fragment.app.DialogFragment$4.onChanged(DialogFragment.java:140)
at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2961)
at androidx.fragment.app.DialogFragment.performCreateView(DialogFragment.java:486)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:515)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2088)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f0400c1 a=2}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:546)
at com.google.android.material.resources.MaterialResources.getColorStateList(MaterialResources.java:71)
at com.google.android.material.bottomsheet.BottomSheetBehavior.<init>(BottomSheetBehavior.java:281)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at androidx.coordinatorlayout.widget.CoordinatorLayout.parseBehavior(CoordinatorLayout.java:647)
at androidx.coordinatorlayout.widget.CoordinatorLayout$LayoutParams.<init>(CoordinatorLayout.java:2896)
at androidx.coordinatorlayout.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:1740)
at androidx.coordinatorlayout.widget.CoordinatorLayout.generateLayoutParams(CoordinatorLayout.java:112)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
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.view.View.inflate(View.java:24354)
at com.google.android.material.bottomsheet.BottomSheetDialog.ensureContainerAndBehavior(BottomSheetDialog.java:188)
at com.google.android.material.bottomsheet.BottomSheetDialog.wrapInBottomSheet(BottomSheetDialog.java:200)
at com.google.android.material.bottomsheet.BottomSheetDialog.setContentView(BottomSheetDialog.java:93)
at androidx.fragment.app.DialogFragment$4.onChanged(DialogFragment.java:155)
at androidx.fragment.app.DialogFragment$4.onChanged(DialogFragment.java:140)
at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2961)
at androidx.fragment.app.DialogFragment.performCreateView(DialogFragment.java:486)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:515)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2088)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I've tried to override background tint like this
<style name="CustomBottomSheet" parent="Widget.MaterialComponents.BottomSheet">
<item name="backgroundTint">#color/white</item>
</style>
Then it works! But the bottom sheet gets huge padding at left and right side (i.e. not from edge to edge of the screen). As I see there's some issue with default value ?attr/colorSurface, when I set <item name="backgroundTint">?attr/colorSurface</item> app crashes, why does that happen?
Crash was because of missing ?attr/colorSurface in the theme, had to add it to the main app theme that was used.
<style name="Common.MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary_material</item>
<item name="colorPrimaryDark">#color/primary_material</item>
<item name="colorAccent">#color/primary_accent</item>
<item name="colorSurface">#color/white</item> <-- added it explicitly
<item name="bottomSheetDialogTheme">#style/Common.BottomSheet.Rounded</item>
</style>
I have been trying to implement dynamic them in my project but for some reason its giving the following error. this is how i tried to implement it.
First i defined some custom attributes like:
<resources>
<attr name="themeWindowBackground" format="reference" />
<attr name="themeContentBackground" format="reference" />
<attr name="themeContentTextColor" format="reference" />
<attr name="themeContentTextColorOnPrimary" format="reference" />
<attr name="themeTextColorSuccess" format="reference" />
<attr name="themeTextColorFailure" format="reference" />
then i defined the custom themes in my style.xml file
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">#drawable/bg_splash_screen</item>
</style>
<style name="AppTheme.Black" parent="AppTheme">
<item name="colorPrimary">#color/material_dark</item>
<item name="colorPrimaryDark">#color/material_primary_dark</item>
<item name="colorAccent">#color/material_accent</item>
<item name="themeWindowBackground">#color/dark_gray</item>
<item name="themeContentBackground">#color/dark_slate_gray</item>
<item name="themeContentTextColor">#color/white</item>
<item name="themeContentTextColorOnPrimary">#color/teal</item>
<item name="themeTextColorSuccess">#color/green</item>
<item name="themeTextColorFailure">#color/red</item>
</style>
</resources>
after that i am setting the theme using this
application.setTheme(mPreferenceRepository.savedTheme)
this the function that is geeting the saved theme
public int getSavedTheme() {
String theme = getStringFromSharedPreference(APP_THEME);
if (theme.equals(THEME_BLUE)) {
return R.style.AppTheme_Blue;
}
return R.style.AppTheme_Black;
}
now when i'm trying to apply theme in my layout or layout content using this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="?attr/themeWindowBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
the application is crashing. this is my message but i can't figure out what i'm doing wrong
Process: com.singularitybd.shellitracker, PID: 2214
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.singularitybd.shellitracker/com.singularitybd.shellitracker.view.activity.LoginActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.singularitybd.shellitracker.view.activity.LoginActivity.onCreate(LoginActivity.kt:44)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f0301ba a=-1}
at android.content.res.TypedArray.getDrawable(TypedArray.java:925)
at android.view.View.<init>(View.java:4202)
at android.view.ViewGroup.<init>(ViewGroup.java:579)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:248)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:244)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:240)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.singularitybd.shellitracker.view.activity.LoginActivity.onCreate(LoginActivity.kt:44)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Application terminated.
if you can provide me some guidance i will be very grateful. Thank you very much.
I just had this problem occurs when I test my app on a old android phone. However it works on new android phone. I finally find out that I save the layout background image in the res\drawable-v24. Remove the image and save back at res\drawable
Hope this solve your problem
I think and as I understand your statements this problem is about second line of RelativeLayout. Try to add another picture to the background, or try typing
android:background="?attr/themeWindowBackground" ` as style.
Like this : style =?attr/themeWindowBackround
This is a old question, but I decided to answer anyway. The problem is that you are referencing to a view that does not exist.
From your log:
Binary XML file line #2: Error inflating class android.widget.RelativeLayout
You are trying to inflate a RelativeLayout that doesn't exist.
This may occur when you added a layout for landscape and you forgot to add the RelativeLayout, or it could be that you are referencing to a RelativeLayout with a incorrect id.
Make sure that the RelativeLayout actually exist and that the correct id is used hen you are referencing to it.
Good evening!
Edited
Here's my situation:
I'm using FirebaseUI to store in FirebaseStorage and FirebaseDatabase, and retrieve from Database only. I'm trying to use a FloatingActionButton in activity_main.xml (actually is the FloatingActionButton included in the Basic Activity you choose once you start a project) to take a picture. But when I compile the next dependencies
compile 'com.firebaseui:firebase-ui-database:1.0.1'
compile 'com.firebaseui:firebase-ui-storage:1.0.1'
it's not possible to run the application. It appears this exception:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: mx.com.jamba.pruebas, PID: 22567
java.lang.RuntimeException: Unable to start activity ComponentInfo{mx.com.jamba.pruebas/mx.com.jamba.pruebas.MainActivity}: android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class android.support.design.widget.FloatingActionButton
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:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
at mx.com.jamba.pruebas.MainActivity.onCreate(MainActivity.java:71)
at android.app.Activity.performCreate(Activity.java:6259)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class android.support.design.widget.FloatingActionButton
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)
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:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
at mx.com.jamba.pruebas.MainActivity.onCreate(MainActivity.java:71)
at android.app.Activity.performCreate(Activity.java:6259)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
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)
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:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
at mx.com.jamba.pruebas.MainActivity.onCreate(MainActivity.java:71)
at android.app.Activity.performCreate(Activity.java:6259)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.NoSuchMethodError: No direct method <init>(Landroid/widget/ImageView;Landroid/support/v7/widget/AppCompatDrawableManager;)V in class Landroid/support/v7/widget/AppCompatImageHelper; or its super classes (declaration of 'android.support.v7.widget.AppCompatImageHelper' appears in /data/data/mx.com.jamba.pruebas/files/instant-run/dex/slice-com.android.support-appcompat-v7-25.0.1_3703da7076adad9ae91e29d9a19b5ed5b7cb0669-classes.dex)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:133)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:110)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
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)
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:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
at mx.com.jamba.pruebas.MainActivity.onCreate(MainActivity.java:71)
at android.app.Activity.performCreate(Activity.java:6259)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
The only line of code that the exception points in my code is the #71, and it has the following piece of code:
setContentView(R.layout.activity_main);
This is my Style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Also, this is my FloatingActionButton in activity_main.xml:
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
app:fabSize="normal"
app:backgroundTint="#color/colorAccent"
android:layout_gravity="bottom|right"
app:srcCompat="#android:drawable/ic_dialog_dialer"
android:id="#+id/floatingActionButton" />
The problem is that when I try to Run 'app' in my Moto G4 Android 6.0.1, the application crashes. I dedicated a little time to compile the project dependency by dependency and I realized that when I erase the FirebaseUI dependencies the application was executed, but without FurebaseUI functions. The way that I found to execute the application was erase the FloatingActionButton and use a normal Button instead, but I need a FloatingActionButton.
If you guys need more info or code, comment and I'll gladly put it in the post!
My name is Victor. I have been stucked with this problem for some hours and cannot manage to get it solved. Here is what happens:
I have got an app which loads this Theme automatically to enable the Sidebar functionability: (AppTheme.ActionBar)
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/black_opaque</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#212121</item>
<item name="android:textColorSecondary">#727272</item>
<item name="textColorError">#color/design_textinput_error_color_dark</item>
</style>
<style name="AppTheme.ActionBar">
<item name="windowActionBar">true</item>
<item name="windowNoTitle">false</item>
Then, I use getWindow().requestFeature(Window.FEATURE_ACTION_BAR); to get the support ActionBar.
It is woking fine in Android versions lower than 6.0. With Android 6.0 it automatically crashes and gives me this error:
07-10 08:16:18.894 3058-3058/com.example.com E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.com, PID: 3058
android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class android.support.v7.view.menu.ActionMenuItemView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.v7.view.menu.BaseMenuPresenter.createItemView(BaseMenuPresenter.java:161)
at android.support.v7.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:180)
at android.support.v7.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:192)
at android.support.v7.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:480)
at android.support.v7.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1138)
at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:91)
at android.support.v7.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:229)
at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:284)
at android.support.v7.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1030)
at android.support.v7.view.menu.MenuBuilder.onItemVisibleChanged(MenuBuilder.java:1065)
at android.support.v7.view.menu.MenuItemImpl.setVisible(MenuItemImpl.java:528)
at com.example.com.MainActivity.showOption(MainActivity.java:882)
at com.example.com.MainActivity.activarConfigHorarios(MainActivity.java:1035)
at com.example.com.DetalleFragment$4.done(DetalleFragment.java:652)
at com.example.com.DetalleFragment$4.done(DetalleFragment.java:555)
at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:116)
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: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 #17: Error inflating class android.support.v7.view.menu.ActionMenuItemView
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.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.v7.view.menu.BaseMenuPresenter.createItemView(BaseMenuPresenter.java:161)
at android.support.v7.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:180)
at android.support.v7.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:192)
at android.support.v7.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:480)
at android.support.v7.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1138)
at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:91)
at android.support.v7.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:229)
at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:284)
at android.support.v7.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1030)
at android.support.v7.view.menu.MenuBuilder.onItemVisibleChanged(MenuBuilder.java:1065)
at android.support.v7.view.menu.MenuItemImpl.setVisible(MenuItemImpl.java:528)
at com.example.com.MainActivity.showOption(MainActivity.java:882)
at com.example.com.MainActivity.activarConfigHorarios(MainActivity.java:1035)
at com.example.com.DetalleFragment$4.done(DetalleFragment.java:652)
at com.example.com.DetalleFragment$4.done(DetalleFragment.java:555)
at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:116)
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: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: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.v7.view.menu.BaseMenuPresenter.createItemView(BaseMenuPresenter.java:161)
at android.support.v7.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:180)
at android.support.v7.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:192)
at android.support.v7.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:480)
at android.support.v7.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1138)
at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:91)
at android.support.v7.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:229)
at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:284)
at android.support.v7.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1030)
at android.support.v7.view.menu.MenuBuilder.onItemVisibleChanged(MenuBuilder.java:1065)
at android.support.v7.view.menu.MenuItemImpl.setVisible(MenuItemImpl.java:528)
at com.example.com.MainActivity.showOption(MainActivity.java:882)
at com.example.com.MainActivity.activarConfigHorarios(MainActivity.java:1035)
at com.example.com.DetalleFragment$4.done(DetalleFragment.java:652)
at com.example.com.DetalleFragment$4.done(DetalleFragment.java:555)
at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:116)
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: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: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 5: TypedValue{t=0x2/d=0x7f010049 a=-1}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:482)
at android.widget.TextView.<init>(TextView.java:1043)
at android.widget.TextView.<init>(TextView.java:671)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
at android.support.v7.view.menu.ActionMenuItemView.<init>(ActionMenuItemView.java:72)
at android.support.v7.view.menu.ActionMenuItemView.<init>(ActionMenuItemView.java:68)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.v7.view.menu.BaseMenuPresenter.createItemView(BaseMenuPresenter.java:161)
at android.support.v7.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:180)
at android.support.v7.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:192)
at android.support.v7.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:480)
at android.support.v7.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1138)
at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:91)
at android.support.v7.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:229)
at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:284)
at android.support.v7.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1030)
at android.support.v7.view.menu.MenuBuilder.onItemVisibleChanged(MenuBuilder.java:1065)
at android.support.v7.view.menu.MenuItemImpl.setVisible(MenuItemImpl.java:528)
at com.example.com.MainActivity.showOption(MainActivity.java:882)
at com.example.com.MainActivity.activarConfigHorarios(MainActivity.java:1035)
at com.example.com.DetalleFragment$4.done(DetalleFragment.java:652)
at com.example.com.DetalleFragment$4.done(DetalleFragment.java:555)
at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:116)
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: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)
In my Java class (at the line where crashes) I am setting the visibility of a MenuItem to true or false.
Here is a model menu class.:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.com.CalendarActivity"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="#+id/action_settings" android:title="#string/action_settings"
android:orderInCategory="100" app:showAsAction="ifRoom" />
</menu>
Could someone help me with this error?
If you need more information or code just let me know it
I have used simple Edit Text in my activity just like below. I have tried different solutions from stack and other resources but it does't solve my issue.
<EditText
android:id="#+id/edtRemarks"
android:layout_width="match_parent"
android:layout_height="80dip"
android:gravity="left|top"
android:hint="Enter comments1"
android:padding="5dp"
android:textSize="16sp"
android:textStyle="normal" />
On long press below error occurs
android.view.InflateException: Binary XML file line #17: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:2928)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2233)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2901)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2901)
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3302)
at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3536)
at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3780)
at android.widget.Editor.performLongClick(Editor.java:866)
at android.widget.TextView.performLongClick(TextView.java:8660)
at android.view.View$CheckForLongPress.run(View.java:19723)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=1552
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:967)
at android.content.res.TypedArray.getString(TypedArray.java:176)
at android.widget.TextView.<init>(TextView.java:1011)
at android.widget.TextView.<init>(TextView.java:629)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:48)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:44)
at android.support.v7.internal.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:912)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:966)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:2928)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2233)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2901)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2901)
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3302)
at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3536)
at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3780)
at android.widget.Editor.performLongClick(Editor.java:866)
at android.widget.TextView.performLongClick(TextView.java:8660)
at android.view.View$CheckForLongPress.run(View.java:19723)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Any idea why this is happening only in 5.0.1 and 5.0.2? it's working fine in <= KITKAT devices.
EDITED:
i found solution here, remove font family from app. but i have used like below. is there way to remove font for edittext only? remain app work with font?
style.xml in values-v21 folder
<style name="AppTheme" parent="AppTheme.Bash">
<item name="homeAsUpIndicator">#null</item>
<item name="android:homeAsUpIndicator">#null</item>
<item name="actionBarStyle">#style/CustomActionBarStyle</item>
<item name="android:actionBarStyle">#style/CustomActionBarStyle</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
Deletes the next line:
<item name="android:fontFamily">sans-serif-light</item>
apparently it does not support Change language in some versions
Fixed it
Delete this line from the theme - styles.xml. Problem may occur due to this font item in the App theme or activity theme or in element theme.
<item name="android:fontFamily"> some fonts </item>
This works for me and get free from Long press crash in lower android versions... Works for both EditText and Material TextInputEditText.