Mobile Development 8 min read

Android P Restricts Non‑Official APIs: Overview, Verification, and Practical Testing

This article explains how Android P disables the use of hidden (non‑SDK) APIs, describes the official restrictions and grey‑list classifications, provides verification steps and download links, and demonstrates a practical reflection test on the WifiManager hidden field, highlighting the impact on developers.

JD Retail Technology
JD Retail Technology
JD Retail Technology
Android P Restricts Non‑Official APIs: Overview, Verification, and Practical Testing

Android P introduces restrictions on non‑official (hidden) APIs—those annotated with @hide and not documented in the SDK. Apps that reference such APIs via reflection, JNI, or other means will be limited, and the system will log or toast warnings.

The article first presents information gathered from recent AOSP commits, confirming that hidden APIs will be blocked. It then offers verification steps: developers can download the Android P preview build from the official site ( developer.android.com/preview/download.html ) and test whether their apps trigger the restrictions.

Official documentation clarifies that the limitation applies to Java‑level hidden APIs, extending earlier N‑level native restrictions. Google’s statement emphasizes improving stability by reducing reliance on undocumented interfaces.

The restrictions are categorized into two grey‑lists:

Light greylist – methods and fields still run in the preview but may be removed in future releases.

Dark greylist – methods that are currently inaccessible.

Logcat entries show the accessed hidden members, their access method (reflection or JNI), and the applicable grey‑list. Example log entries:

Accessing hidden field Landroid/os/Message->flags:I (light greylist, JNI)
Accessing hidden method Landroid/app/ActivityThread->currentActivityThread()Landroid/app/ActivityThread; (dark greylist, reflection)

To illustrate the impact, the article tests a hidden field in android.net.wifi.WifiManager :

/**
 * Broadcast intent action indicating whether Wi‑Fi scanning is allowed currently
 * @hide
 */
public static final String WIFI_SCAN_AVAILABLE = "wifi_scan_available";

Using Java reflection, the field is accessed and logged:

WifiManager wifiManager = (WifiManager) getApplication().getSystemService(Context.WIFI_SERVICE);
field = wifiManager.getClass().getDeclaredField("WIFI_SCAN_AVAILABLE");
Log.d(Tag, (String) field.get(wifiManager));

Running this on an Android P preview device produces a toast warning and a log entry indicating the field is on the dark greylist (reflection), confirming the restriction.

The article concludes that developers should audit their apps for hidden API usage, as Android P will soon enforce these limits, potentially causing crashes or failures if non‑official APIs are used.

AndroidTestingReflectionNon‑SDK APIAndroid Pgreylist
JD Retail Technology
Written by

JD Retail Technology

Official platform of JD Retail Technology, delivering insightful R&D news and a deep look into the lives and work of technologists.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.