Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AndroidStudio disable "Expected resource of type string"

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.

like image 967
Yaroslav Avatar asked Jan 26 '16 08:01

Yaroslav


3 Answers

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.

like image 175
Yaroslav Avatar answered Oct 20 '22 17:10

Yaroslav


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>
like image 35
Alvaro Gutierrez Perez Avatar answered Oct 20 '22 19:10

Alvaro Gutierrez Perez


Maybe a better solution is to temporary disable error/warning by using @SuppressLint("ResourceType") just before the method definition.

like image 7
user7287497 Avatar answered Oct 20 '22 17:10

user7287497