添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

These restrictions are applied whenever an app references a non-SDK interface or attempts to obtain its handle using reflection or JNI... Handling of non-SDK interfaces is an implementation detail that the API abstracts away; it is subject to change without notice... Greylisted non-SDK interfaces encompass methods and fields which continue to function in Android 9, but to which we don't guarantee access in future versions of the platform... You can use adb logcat to access these log messages, which appear under the PID of the running app...

Here are the relevant parts of my code running on an API 28 Emulator:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
           ................       
    MobileAds.initialize(this,  "ca-app-pub-3940256099942544~3347511713");
           ................
    adView = new AdView(this);
    adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
    adView.setAdSize(AdSize.BANNER);
    adView.setBackgroundColor(Color.TRANSPARENT);
    adView.setVisibility(View.GONE);            
    adView.loadAd(adBuilder());
           ................
    interstitial = new InterstitialAd(GLGame.this);            
    interstitial.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
    interstitial.loadAd(adBuilder());        
    mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
    mRewardedVideoAd.setRewardedVideoAdListener(this);        
    loadRewardedVideoAd();        
AdRequest adBuilder() {
    return new AdRequest.Builder().build();
public void loadRewardedVideoAd() {        
    mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917", new AdRequest.Builder().build());        

I found that with

MobileAds.initialize(this,  "ca-app-pub-3940256099942544~3347511713");
adView.loadAd(adBuilder());
interstitial.loadAd(adBuilder());

my Logcat output is:

W: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;-><init>(Landroid/content/Context;I)V (light greylist, reflection)
W: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V (light greylist, reflection)
W: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextSelection;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)

if i disable by commenting

//MobileAds.initialize(this,  "ca-app-pub-3940256099942544~3347511713");
//adView.loadAd(adBuilder());
//interstitial.loadAd(adBuilder());

the Accessing hidden logcat goes away.

Same as before i got Logcat output:

W: Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (light greylist, reflection)

if i disable by commenting

//loadRewardedVideoAd();

the Accessing hidden logcat goes away.

As you can see the code:

MobileAds.initialize(this,  "ca-app-pub-3940256099942544~3347511713");
adView.loadAd(adBuilder());
interstitial.loadAd(adBuilder());
loadRewardedVideoAd();

caused a lot of Accessing hidden logcat.

My questions are:

  • These are a problem of the emulator?
  • Is it possible that i make usage of NON-SDK interfaces (see Accessing hidden methods, light greylist, reflection) that will break my app in future versions of the platform?
  • How can this be fixed?
  • It looks like whatever mobile ad library you're using is doing it. It is a risk, it means that you need to keep that library updated if a new version of android breaks that. – Gabe Sechan Oct 7, 2018 at 16:14 Looking at what its actually doing- it looks like they're trying to use features of Android9 that may have existed before that via reflection. Which is fairly safe. What they're doing it trying to manipulate the text classification subsystem to change what's displayed in the contextual action bar (things like copy, paste, etc). – Gabe Sechan Oct 7, 2018 at 16:23 Hello @Gabe, i use: implementation 'com.google.android.gms:play-services-ads:9.8.0' and some other google-play-services. If i update to current 16.0.0 i can build and run without problem except that i get 71 lint Deprecated API usage warnings But the Accessing hidden logcat remains the same with google-play-services:9.8.0 Could you please tell me, if i update to google-play-services:16.0.0 and replace the Deprecated API usage 71 Warnings this problem will be fixed? – Kostas Trakos Oct 7, 2018 at 18:54 I wouldn't worry about the warnings. Like I said- it looks like this functionality existed before Android 9, was made public in Android 9, but they're trying to make use of it in some older versions where it exists. That's a safe usage. When Android 9.1 or 10 comes out your should double check nothing breaks on them, but I think it unlikely. – Gabe Sechan Oct 7, 2018 at 19:03 When Android 9.1 or 10 will come, if something breaks on them which will be the steps to fix it? – Kostas Trakos Oct 7, 2018 at 19:52

    Greylisted non-SDK interfaces means methods and fields which continue to function in Android 9, but to which google doesn't guarantee access in future versions of the platform. If there is a reason that you cannot implement an alternative strategy to a greylisted API, you may file a bug to request reconsideration of the restriction.

    https://issuetracker.google.com/issues/new?component=328403&template=1027267

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.