Android 7.0添加GMS包后,编译时会出现WebViewGoogle报错:

  1. ro.product.first_api_level property is undefined

这行log出自脚本文件:

  1. \vendor\google\apps\WebViewGoogle\Android.mk
  2. # make sure to include correct WebView binary: full or stub
  3. _list_of_old_api_levels := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
  4. ifneq (,$(filter $(PLATFORM_SDK_VERSION),$(_list_of_old_api_levels)))
  5. # WebView apks in this folder are for N or later platforms only, stop building
  6. $(error PLATFORM_SDK_VERSION must be equal to or greater than 24)
  7. endif
  8. _ro_property_string := $(filter ro.product.first_api_level=%,$(ADDITIONAL_BUILD_PROPERTIES))
  9. ifdef _ro_property_string
  10. _first_api_level := $(word 2,$(subst =,$(space),$(_ro_property_string)))
  11. else
  12. # if the first_api_level property is undefined, stop building
  13. $(error ro.product.first_api_level property is undefined)
  14. endif

如上脚本倒数第二行,即是log出处。

解决办法:

在 _ro_property_string 那行脚本上面插入新脚本:

  1. ADDITIONAL_BUILD_PROPERTIES += ro.product.first_api_level=24
  2. _ro_property_string := $(filter ro.product.first_api_level=%,$(ADDITIONAL_BUILD_PROPERTIES))