Skip to content

[ Important ] Violations on android P Restrictions on non-SDK interfaces #19067

@narychen

Description

@narychen

Run react-native app on android P emulator will throw out a caution of non-sdk usage.
The link is https://developer.android.com/preview/restrictions-non-sdk-interfaces
And a bunch of react-native native android code use refection or other non-sdk that will cause
the app not working on Android P.
A example piece of code is in ReactTextInputManager.java

  private void setCursorColor(ReactEditText view, @Nullable Integer color) {
    // Evil method that uses reflection because there is no public API to changes
    // the cursor color programmatically.
    // Based on http://stackoverflow.com/questions/25996032/how-to-change-programatically-edittext-cursor-color-in-android.
    try {
      // Get the original cursor drawable resource.
      Field cursorDrawableResField = TextView.class.getDeclaredField("mCursorDrawableRes"); 
      cursorDrawableResField.setAccessible(true);
      int drawableResId = cursorDrawableResField.getInt(view);

      // T

Use reflection TextView.class.getDeclaredField("mCursorDrawableRes")

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPlatform: AndroidAndroid applications.Ran CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions