TextInputLayout error: Couldn't resolve resource @string/path_password_strike_through

主宰稳场 提交于 2021-02-08 21:33:13

问题


AndroidX: I'm trying to use a TextInputLayout but when I put it in my XML I receive this error:

Render Problem:

Couldn't resolve resource @string/path_password_strike_through

Failed to initiate one or more classes

The following classes could not be instantiated:
        com.google.android.material.textfield.TextInputLayout

Here the Stack Trace:

java.lang.AssertionError: error in parsing "g/"java.lang.NumberFormatException: For input string: "/"
    at android.util.PathParser_Delegate.getFloats(PathParser_Delegate.java:366)
    at android.util.PathParser_Delegate.createNodesFromPathData(PathParser_Delegate.java:183)
    at android.util.PathParser_Delegate.nCreatePathDataFromString(PathParser_Delegate.java:107)
    at android.util.PathParser.nCreatePathDataFromString(PathParser.java)
    at android.util.PathParser.access$200(PathParser.java:24)
    at android.util.PathParser$PathData.<init>(PathParser.java:76)
    at android.graphics.drawable.VectorDrawable$VFullPath.updateStateFromTypedArray(VectorDrawable.java:2016)
    at android.graphics.drawable.VectorDrawable$VFullPath.inflate(VectorDrawable.java:1967)
    at android.graphics.drawable.VectorDrawable.inflateChildElements(VectorDrawable.java:819)
    at android.graphics.drawable.VectorDrawable.inflate(VectorDrawable.java:717)
    at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
    at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
    at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1266)
    at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:330)
    at android.content.res.Resources_Delegate.getDrawable(Resources_Delegate.java:186)
    at android.content.res.Resources.getDrawable(Resources.java:827)
    at android.graphics.drawable.AnimatedVectorDrawable.inflate(AnimatedVectorDrawable.java:544)
    at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
    at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
    at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1266)
    at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:330)
    at android.content.res.BridgeTypedArray.getDrawable(BridgeTypedArray.java:684)
    at android.graphics.drawable.AnimatedStateListDrawable.parseTransition(AnimatedStateListDrawable.java:473)
    at android.graphics.drawable.AnimatedStateListDrawable.inflateChildElements(AnimatedStateListDrawable.java:455)
    at android.graphics.drawable.AnimatedStateListDrawable.inflate(AnimatedStateListDrawable.java:385)
    at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
    at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
    at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1266)
    at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:330)
    at android.content.res.Resources_Delegate.getDrawable(Resources_Delegate.java:186)
    at android.content.res.Resources.getDrawable(Resources.java:827)
    at android.content.Context.getDrawable(Context.java:626)
    at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:463)
    at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:203)
    at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
    at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:102)
    at androidx.appcompat.widget.TintTypedArray.getDrawable(TintTypedArray.java:76)
    at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:344)
    at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:247)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:401)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:184)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:142)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:229)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:421)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:432)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:336)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:327)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:386)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:450)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:590)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

I 'm trying to use more the 'android.material.xxx' than support.design.widget.

I also tried the support.design version but it doesn't seems to work :/ What might be the problem here ? Thanks in advice.


回答1:


Had the same problem..

Adding the following line of code to your TextInputLayout will fix this issue:

app:passwordToggleDrawable="@string/string_name"

Worked for me



来源:https://stackoverflow.com/questions/51427353/textinputlayout-error-couldnt-resolve-resource-string-path-password-strike-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!