想给Androird JellyBean 4.1.0的framework里面添加一个res,把xml写好以后编译时候报错
int ticker = com.android.internal.R.string.xxxxxxxxxx;
^
frameworks/base/services/java/com/android/server/StatusBarManagerService.java:143: cannot find symbol
symbol : variable xxxxxxxxxx
location: class com.android.internal.R.drawable
解决办法很简单,在MakeJavaSymbols.sed里面有:
# Run this on the errors output by javac of missing resource symbols,
# to generate the set of <java-symbol> commands to have aapt generate
# the symbol for them.
#
#
For example: make framework 2>&1 | sed -n -f MakeJavaSymbols.sed | sort -u重新编译会产生
<java-symbol type="string" name="xxxxxxxxxx" />
把这个copy到publlic.xml。再重新编译一次就搞定了。
public.xml也提到
<!-- Private symbols that we need to reference from framework code. See
frameworks/base/core/res/MakeJavaSymbols.sed for how to easily generate
this.
-->
看起来所有private的internal res都必须在这里声明一下。JellyBean以前貌似没有这么麻烦。好在他提供了一个sed,免得全部手写。