You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android安全路径版本升级后SQLiteQueryBuilder投影报错原因咨询

Why does my SQLiteQuery projection throw "Invalid column null" on newer Android versions?

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 17:22:36