问题描述
GtsUnofficialApisUsageTestCases
com.android.gts.api.UnofficialApisUsageTest#testNonApiReferences
Fail:
Fail:
junit.framework.AssertionFailedError: Undefined method ref: java.util.Collections.max(java.util.Collection)java.lang.Object from: /vendor/app/EmCamera/EmCamera.apk
解决方案
报错的原因是由于:
1. 在GTS 中有说明:Ensures that java modules in vendor partition on the device are not using any non-approved APIs
即vendor下的java modules不可以使用non-approved APIs。2. 在GMS Requirements 中有明确说明:
All APKs and JARs in the vendor partition MUST NOT use hidden APIs defined in the system partition which are neither an Android API nor an @SystemApi.
1. 在GTS 中有说明:Ensures that java modules in vendor partition on the device are not using any non-approved APIs
即vendor下的java modules不可以使用non-approved APIs。2. 在GMS Requirements 中有明确说明:
All APKs and JARs in the vendor partition MUST NOT use hidden APIs defined in the system partition which are neither an Android API nor an @SystemApi.
3. Google从Android P开始限制对Non-SDK interface(内部API)的使用,因此将APK预制到vendor下将受此影响
详情请参考Google文档
https://developer.android.com/distribute/best-practices/develop/restrictions-non-sdk-interfaces
EmCamera.apk 是用于测试和debug 用的, 最终客户版本可以删除