Operator '+' cannot be applied to int,'com.fasterxml.jackson.core.io.SerializedString'

243 Views Asked by At

I'm facing Operator '+' cannot be applied to int,'com.fasterxml.jackson.core.io.SerializedString' Error in run method of a thread. Here's the code block

runOnUiThread(new Runnable() {
                public void run() {
                    ActivityHome.this.scanning_following.setText(ActivityHome.this.mapB.size()
                            + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR
                            + ActivityHome.this.getResources().getString(R.string.following)
                            + " scanned");
                }
            });
1

There are 1 best solutions below

0
On BEST ANSWER

Either MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR or ActivityHome.this.getResources().getString(R.string.following) is not a java.lang.String, so you can't apply + operator to it.

You can easily convert them to java.util.String by calling toString() (this is assuming com.fasterxml.jackson.core.io.SerializedString has a meaningful implementation of toString()):

runOnUiThread(new Runnable() {
                public void run() {
                    ActivityHome.this.scanning_following.setText(ActivityHome.this.mapB.size()
                            + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR.toString()
                            + ActivityHome.this.getResources().getString(R.string.following).toString()
                            + " scanned");
                }
            });