You have tried to change the API from what has been previously released in
an SDK. Please fix the errors listed above.
android Q 标准类新增api错误
Aborting: Found compatibility problems checking the public API against the API in /android/out/soong/.intermediates/prebuilts/sdk/last-releas
ed-public-api/gen/last-released-api.txt
You have tried to change the API from what has been previously released in
an SDK. Please fix the errors listed above.
没有下文了!!!也不给我update-api的机会了。这是由于google对安卓10进一步限制了反射以及非开放sdk的使用。
那么怎么解决这个问题呢。搜索这个文件last-released-api.txt
在prebuilts/sdk/Android.bp下有生成规则
genrule {
name: "last-released-public-api",
srcs: [
"*/public/api/android.txt",
],
cmd: "cp -f $$(echo $(in) | tr \" \" \"\\n\" | sort -t/ -k3 -n | tail -1) $(genDir)/last-released-api.txt",
out: [
"last-released-api.txt",
],
}
这个生成规则大致可以看出来是在prebuilts/sdk/n(数字api等级,如29)的public/api/下android.txt文件。
那么通过对比得知out目录下的last-released-api.txt文件由这个android.txt文件生成。
那就简单了把framework/base/api/current.txt覆盖到这个android.txt下即可。
cp frameworks/base/api/current.txt prebuilts/sdk/29/public/api/android.txt
自己排查了一会儿希望对大家有用。期间还有一些坑。例如注释build/make/core/definitions.mk
里的check-api方法是没用的。不再细究。