<expr> expected, got '?'

Flarosa picture Flarosa · Oct 30, 2017 · Viewed 9.4k times · Source

When typing a SQLite statement as a string literal in a class in Android Studio, the IDE gives me this warning: "<expr> expected, got '?'".

I don't understand what this means, but the code is working fine, and I'd like to disable the inspection. But I don't know which inspection is causing it. There are thousands of them, and searching for or expected yields no useful results.

The version of Android Studio is 3.0. It's happening with a whole bunch of different statements, but a typical one looks like this:

SQLiteStatement st = db.compileStatement(
   "INSERT OR REPLACE INTO routes(route_code, route_desc) VALUES(?,?)"
);

Answer

Henry picture Henry · Dec 14, 2017

This is a bug in Android Studio 3.0 and is already reported here. Also this is now fixed in the 3.1 version. I am using the latest Canary 5 3.1 build and it works fine.

Since there are not going to be anymore 3.0 patches, all you can do for now is to go with the workaround or disable this lint check.