0

I have this strange behaviour where on my Samsung Galaxy I get this bug where it can't find the class R$styleable. When I run the same code on my Nexus 5 or Nexus 4 I don't get the problem and everything works fine.

The line where I get this exception is in my custom Spinner implementation ImageSpinner:

TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ImageSpinner);

This is the exception I get:

java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package.name/my.package.name.NavigationSetupActivity}: android.view.InflateException: Binary XML file line #39: Error inflating class my.package.name.views.ImageSpinner

Caused by: java.lang.NoClassDefFoundError: my.package.name.R$styleable

This is the stylable file located in the values/attrs.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="ImageSpinner">
        <attr name="arrowTint" format="color" />
        <attr name="hideArrow" format="boolean" />
    </declare-styleable>
</resources>

The OS version of the Samsung Galaxy phone is 4.2.2 (CyanogenMod) but also on stock Samsung Android OS it crashes. The Nexus 5 is 6.0.1 and Nexus 4 is a lollipop version. Thhe sdk tools and compile version are following:

compileSdkVersion 23
buildToolsVersion '23.0.2'
minSdkVersion 16
targetSdkVersion 23

I tried to clean the project and check the resource files and everything seems to be ok, but I really have no more ideas how to approach this problem. Does anyone have an idea how to fix this?

Thank you for your time!

Aksiom
  • 1,565
  • 4
  • 25
  • 39

1 Answers1

1

If you are running the app on older versions, then you have to change the: compile-sdk to lower sdks. That is why the app works on some newer phones and it does not on some other phones you mentioned. check out this link

Styeleable class has been removed from the newer SDKs because the attributes are changing constantly between SDK releases. That is why you are getting that error inorder to use Styleable class, you must use older versions of SDKs

java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package.name/my.package.name.NavigationSetupActivity}: android.view.InflateException: Binary XML file line #39: Error inflating class my.package.name.views.ImageSpinner


Caused by: java.lang.NoClassDefFoundError: my.package.name.R$styleable
Community
  • 1
  • 1
john doe
  • 157
  • 1
  • 10