Skip to content
This repository has been archived by the owner on Nov 22, 2017. It is now read-only.

Can't convert value at index 5 to dimension: type=0x12 #123

Open
jbmlaird opened this issue May 29, 2017 · 1 comment
Open

Can't convert value at index 5 to dimension: type=0x12 #123

jbmlaird opened this issue May 29, 2017 · 1 comment
Labels

Comments

@jbmlaird
Copy link

jbmlaird commented May 29, 2017

This stacktrace appears when trying to call initializeView() for the first time.

compileSdkVersion 25
buildToolsVersion "25.0.2"
minSdkVersion 21
targetSdkVersion 25

FATAL EXCEPTION: main
Process: bj.draggablepaneltest, PID: 24274
java.lang.RuntimeException: Unable to start activity ComponentInfo{bj.draggablepaneltest/bj.draggablepaneltest.main.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class com.github.pedrovgs.DraggableView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6692)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
 Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class com.github.pedrovgs.DraggableView
 Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.github.pedrovgs.DraggableView
 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:652)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:496)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
    at android.view.View.inflate(View.java:22183)
    at com.github.pedrovgs.DraggablePanel.initializeView(DraggablePanel.java:263)
    at bj.draggablepaneltest.main.DraggablePanelInitialiser.initaliseDraggablePanel(DraggablePanelInitialiser.java:23)
    at bj.draggablepaneltest.main.MainActivity.onCreate(MainActivity.java:36)
    at android.app.Activity.performCreate(Activity.java:6912)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6692)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
 Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 5 to dimension: type=0x12
    at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:737)
    at com.github.pedrovgs.DraggableView.initializeAttributes(DraggableView.java:680)
    at com.github.pedrovgs.DraggableView.<init>(DraggableView.java:85)
    at java.lang.reflect.Constructor.newInstance0(Native Method) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:652) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:496) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:427) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:378) 
    at android.view.View.inflate(View.java:22183) 
    at com.github.pedrovgs.DraggablePanel.initializeView(DraggablePanel.java:263) 
    at bj.draggablepaneltest.main.DraggablePanelInitialiser.initaliseDraggablePanel(DraggablePanelInitialiser.java:23) 
    at bj.draggablepaneltest.main.MainActivity.onCreate(MainActivity.java:36) 
    at android.app.Activity.performCreate(Activity.java:6912) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985) 
    at android.app.ActivityThread.-wrap14(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6692) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358) 

This refers to line: this.marginRight = attributes.getDimensionPixelSize(5, 30); and I have tried overriding marginRight in both XML and code.

I have tried copying the sample dimens.xml and using that but it doesn't work. I have tried in both Kotlin and Java.

draggable_panel.setFragmentManager(supportFragmentManager)
draggable_panel.setTopFragment(youtubeFragment)
draggable_panel.setBottomFragment(EmptyFragment())
draggable_panel.isClickToMaximizeEnabled = truedraggable_panel.setEnableHorizontalAlphaEffect(true)
draggable_panel.setTopFragmentMarginBottom(resources.getDimension(R.dimen.top_fragment_margin).toInt())
draggable_panel.setTopFragmentMarginRight(resources.getDimension(R.dimen.top_fragment_margin).toInt())
draggable_panel.initializeView()
@jbmlaird
Copy link
Author

To avoid the issue I downloaded a local copy of the repository and removed the NineOldAndroids dependency and it worked as expected.

This is just a band-aid and am curious for a proper fix.

@pedrovgs pedrovgs added the bug label Jun 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants