Android P(API 28)-违反StrictMode策略“ SmartSelectionEventTracker $SelectionEvent;-> selectionAction”是

Android P(API 28)-违反StrictMode策略“ SmartSelectionEventTracker $SelectionEvent;-> selectionAction”是,第1张

概述我正在使用StrictMode来查找非SDK用法:if(BuildConfig.DEBUG&&Build.VERSION.SDK_INT>=Build.VERSION_CODES.P){StrictMode.setVmPolicy(newStrictMode.VmPolicy.Builder().detectNonSdkApiUsage().penaltyLog().build(

我正在使用StrictMode来查找非SDK用法:

if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()            .detectNonSdkAPIUsage()            .penaltyLog()            .build());}

现在,我违反了政策:

D/StrictMode: StrictMode policy violation: androID.os.strictmode.NonSdkAPIUsedViolation: LandroID/vIEw/textclassifIEr/logging/    SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroID/vIEw/textclassifIEr/TextClassification;)LandroID/vIEw/textclassifIEr/logging/    SmartSelectionEventTracker$SelectionEvent;        at androID.os.StrictMode.lambda$static(StrictMode.java:428)        at androID.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(UnkNown Source:2)        at java.lang.class.getDeclaredMethodInternal(Native Method)        at java.lang.class.getPublicmethodRecursive(Class.java:2075)        at java.lang.class.getmethod(Class.java:2063)        at java.lang.class.getmethod(Class.java:1690)        at bzi.a(Sourcefile:11)        at bzq.a(Sourcefile:12)        at org.chromium.content.browser.selection.SmartSelectionClIEnt.<init>(Sourcefile:5)        at bzZ.a(UnkNown Source:7)        at org.chromium.androID_webvIEw.AwContents.e(Sourcefile:193)        at org.chromium.androID_webvIEw.AwContents.d(Sourcefile:153)        at org.chromium.androID_webvIEw.AwContents.<init>(Sourcefile:81)        at uY.run(Sourcefile:15)        at ahv.a(Sourcefile:13)        at ahw.run(Sourcefile:2)        at org.chromium.base.ThreadUtils.b(Sourcefile:31)        at ahv.a(Sourcefile:7)        at com.androID.webvIEw.chromium.WebVIEwChromiumFactoryProvIDer.b(Sourcefile:6)        at com.androID.webvIEw.chromium.WebVIEwChromium.init(Sourcefile:111)        at androID.webkit.WebVIEw.<init>(WebVIEw.java:678)        at androID.webkit.WebVIEw.<init>(WebVIEw.java:604)        at androID.webkit.WebVIEw.<init>(WebVIEw.java:587)        at androID.webkit.WebVIEw.<init>(WebVIEw.java:574)        at java.lang.reflect.Constructor.newInstance0(Native Method)        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)        at androID.vIEw.LayoutInflater.createVIEw(LayoutInflater.java:647)        at com.androID.internal.policy.PhoneLayoutInflater.onCreateVIEw(PhoneLayoutInflater.java:58)        at androID.vIEw.LayoutInflater.onCreateVIEw(LayoutInflater.java:720)        at androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:788)        at androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:730)        at androID.vIEw.LayoutInflater.rInflate(LayoutInflater.java:863)        at androID.vIEw.LayoutInflater.rInflateChildren(LayoutInflater.java:824)        at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:515)        at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:423)        at com.mine.ui.events.EventScreen.onCreateVIEw(EventScreen.java:70)        at androID.support.v4.app.Fragment.performCreateVIEw(Fragment.java:2354)        at androID.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:1419)        at androID.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)        at androID.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:1809)        at androID.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)        at androID.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)        at androID.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)        at androID.support.v4.app.FragmentManagerImpl.removeRedundantoperationsAndExecute(FragmentManager.java:2322)        at androID.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)        at androID.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:781)        (... shortened ...)

重要的一行是:

at com.mine.ui.events.EventScreen.onCreateVIEw(EventScreen.java:70)

检查上述行:

public VIEw onCreateVIEw(LayoutInflater inflater, VIEwGroup container, Bundle savedInstanceState){// This is the important line:VIEwGroup content = (VIEwGroup) inflater.inflate(R.layout.mine_event, container, false);WebVIEw webVIEw = (WebVIEw) content.findVIEwByID(R.ID.container);webVIEw.loadUrl(event.getWebVIEwUrl());webVIEw.getSettings().setJavaScriptEnabled(true);(...)

所以我在通货膨胀发生时得到了违规,我不太了解.

如您所见,在提到的那行之后不久,WebVIEw开始起作用.我看了SmartSelectionEventTracker here的源代码,它看起来像是TextVIEws,WebVIEws等控件的通用类.
WebVIEws似乎与MockVIEws有关,后者与TextVIEws有关.

但是除了这一发现之外,我还不知道违规的发生原因/原因以及我可以采取什么措施.

有人可以向我解释吗?

解决方法:

在AndroID P中,限制已添加到私有API(即,不属于公共SDK且可以通过反射访问的API).查看Restrictions on non-SDK interfaces:

AndroID 9 (API level 28) introduces new restrictions on the use of non-SDK interfaces, whether directly, via reflection, or via JNI. These restrictions are applIEd whenever an app references a non-SDK interface or attempts to obtain its handle using reflection or JNI. For more information about this decision, see Improving Stability by Reducing Usage of non-SDK Interfaces.

这就是您所看到的-这是一个警告,表明正在访问某些将来可能会删除的私有API.但是,正如您提到的,堆栈跟踪显示这是来自WebVIEw.特别是在初始化SmartSelectionClient期间.它将初始化隐式访问SmartSelectionEventTracker的本机库,该库在其Javadoc语句中用@hIDe标记,这表明它不属于公共SDK.

简而言之,对于此特定警告,您可能无能为力,所以我不必担心.它发生在设备的Chromium WebVIEw实现中,因此不在应用程序的控制范围之内.由于AndroID和Chromium都是由Google发布的,因此,如果将来的版本中存在合法问题,则将在问题发生之前将更新发布到WebVIEw实施中.

总结

以上是内存溢出为你收集整理的Android P(API 28)-违反StrictMode策略“ SmartSelectionEventTracker $SelectionEvent;-> selectionAction”是全部内容,希望文章能够帮你解决Android P(API 28)-违反StrictMode策略“ SmartSelectionEventTracker $SelectionEvent;-> selectionAction”是所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1095089.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存