想給Androird JellyBean 4.1.0的framework里面添加一個(gè)res,把xml寫(xiě)好以后編譯時(shí)候報(bào)錯(cuò)
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
解決辦法很簡(jiǎn)單,在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重新編譯會(huì)產(chǎn)生
<java-symbol type="string" name="xxxxxxxxxx" />
把這個(gè)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.
-->
看起來(lái)所有private的internal res都必須在這里聲明一下。JellyBean以前貌似沒(méi)有這么麻煩。好在他提供了一個(gè)sed,免得全部手寫(xiě)。