问题
I've just tried to generate signed apk for one of my projects (I already did this before), but (maybe since updating Android Studio) I'm getting
Error:Error: Expected resource of type string [ResourceType]
This is because I'm using Butterknife's @BindString, that is generated into something like that
target.settings = res.getString(2131230792);
How can I make studio not detect this as error? I've tried searching in settings, but without success.
回答1:
This is reported on the GitHub project. It will be fixed in the next version of ButterKnife.
The workaround is indicated there, and is to add a lint.xml
file on the app
module with the following content to ignore that errors on *$$ViewBinder
classes (the ones that ButterKnife generates):
<issue id="ResourceType">
<!-- Remove this when this is fixed: https://github.com/JakeWharton/butterknife/issues/338 -->
<ignore path="**/*$$ViewBinder.java" />
</issue>
回答2:
Answer to this is: disable lint rule in your build.gradle
android {
lintOptions {
disable "ResourceType"
}
}
Edit: This may happen particularly when migrating from Eclipse to Android Studio.
回答3:
Maybe a better solution is to temporary disable error/warning by using @SuppressLint("ResourceType")
just before the method definition.
回答4:
I has a similar problem. with a getString method. Turned out i was trying to get the string value not from strings.xml but from ids.xml, because i was getting it with getString(R.id.MYSTRING), when it should be R.string.MYSTRING
回答5:
this is for some Views by same id and u try to change some property for one of them. When try to generate apk android find some confilict about resours id
To solve that
better way find the code and try solve that from another way to your purpose
GoodLuck
来源:https://stackoverflow.com/questions/35009832/androidstudio-disable-expected-resource-of-type-string