Android安全路径版本升级后SQLiteQueryBuilder投影报错原因咨询
Great catch on fixing this issue with String[] selectFields = { "pmp_id" };—let’s break down exactly why your original code worked pre-2020-01-01 but fails on newer Android security patch levels.
The root of the problem
Your original code creates a String array of length 5, but only assigns a value to the first index:
String[] selectFields = new String[5]; selectFields[0] = "pmp_id";
This leaves the remaining 4 elements of the array set to their default value: null.
Old Android behavior (pre-2020-01-01)
Older versions of SQLiteQueryBuilder were more lenient when processing projection arrays. They would automatically ignore or filter out null values from the projection list, so only your valid "pmp_id" column was used in the final SQL query. No nulls made it to the query logic, so no exception was thrown.
Newer Android behavior (2020-01-01 and later)
Starting with the 2020-01-01 Android security patch, the SQLiteQueryBuilder added stricter validation in methods like computeSingleProjectionOrThrow (as seen in your stack trace). Now, when building the projection, it explicitly checks each element in the array for null. If any null is found, it immediately throws an IllegalArgumentException with the message "Invalid column null"—since SQL doesn’t allow null as a column identifier, and this check helps prevent accidental malformed queries or potential edge cases.
Why your fix works
When you use String[] selectFields = { "pmp_id" };, you’re creating an array of length 1 with only the valid column name, no null values included. This passes the stricter validation in the newer SQLiteQueryBuilder logic, so the query runs without issues.
内容的提问来源于stack exchange,提问作者Cleverton dos santos

