Google's Android repository code cannot be com

2019-08-10 03:02发布

I downloaded an application (Calendar) from the Android repository.

I tried to compile it, but it gave me errors.

As a developer, the first RULE about repositories I learned was this:

Commit your code IF it can be compiled without errors.

On compile, I get these errors:

Error:(38, -1) android-apt-compiler: [Calendar] C:\Dev\Calendar\res\layout\location_dropdown_item.xml:38: error:  Error: No resource found that matches the given name (at 'textColor' with value '@drawable/list_item_font_primary'). 
Error:(46, -1) android-apt-compiler: [Calendar] C:\Dev\Calendar\res\layout\location_dropdown_item.xml:46: error: Error: No resource found that matches the given name (at 'textColor' with value '@drawable/list_item_font_secondary').    
Error:(44, -1) android-apt-compiler: [Calendar] C:\Dev\Calendar\res\layout\recurrencepicker.xml:44: error: Error: No resource found that matches the given name (at 'background' with value '@color/white').

And really, the mentioned xml files are missing from the drawable package. What do yo reckon: was this commit checked?

What should I use instead of those drawables? Color Black? Or Color Red? What is the best way to resolve this issue?

If Google doesn't comply with standards, who will?

1条回答
戒情不戒烟
2楼-- · 2019-08-10 03:38

I think what Justin Jasman is hinting at is that the individual repositories that make up the Android source code aren't designed to be checked out and built by themselves. They’re designed to be built as part of the entire Android source tree, which will pull in dependencies as part of the build process:

AOSP: Downloading and Building

Having said that, you can get some hints about any external dependencies by taking a look at the project.properties file. For instance, near the top of that file you’ll see this line:

android.library.reference.1=../../../frameworks/ex/chips

Which corresponds to a location in the platform/frameworks/ex repository. So if you were to check out that repository:

git clone https://android.googlesource.com/platform/frameworks/ex

And look in the ex/chips/res/drawable folder, you’ll find a couple files that might prove useful:

list_item_font_primary.xml
list_item_font_secondary.xml

Copying those files into res/drawable will fix the first two errors you listed.

Similarly, regarding the third error, you'll find the resource for that in the platform/frameworks/opt/datetimepicker repository. Or you could just change the value from @color/white to @android:color/white
(https://stackoverflow.com/a/3964048/399105)

Edit:

I just noticed some apps in the Android source repos don't have a project.properties file. In that case, you can just look at the Android.mk file, for example (from platform/packages/apps/Mms):

chips_dir := ../../../frameworks/ex/chips/res
查看更多
登录 后发表回答