Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StrictMode: StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation in MainActivity.onCreate #148268

Closed
lukehutch opened this issue May 13, 2024 · 4 comments
Labels
r: solved Issue is closed as solved

Comments

@lukehutch
Copy link
Contributor

Steps to reproduce

I get a lot of StrictMode: StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation exceptions in MainActivity.onCreate.

Expected results

--

Actual results

See log below

Code sample

Code sample

My MainActivity.onCreate is just:

   override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       Log.i("app.clicksocial", "************* MainActivity.onCreate() *************")
   }

Screenshots or Video

N/A

Logs

Logs
05-13 02:24:39.218 21090 21090 I app.clicksocial: ************* MainActivity.configureFlutterEngine() *************
05-13 02:24:39.241 21090 21090 D StrictMode: StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/view/accessibility/AccessibilityNodeInfo;->getSourceNodeId()J
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.os.StrictMode.lambda$static$1(StrictMode.java:416)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.Class.getDeclaredMethodInternal(Native Method)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.Class.getPublicMethodRecursive(Class.java:2079)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.Class.getMethod(Class.java:2066)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.Class.getMethod(Class.java:1693)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder$b.<init>(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder$b.<init>(SourceFile:2)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder.<init>(Unknown Source:6)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.view.i.<init>(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.embedding.android.B.n(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.embedding.android.j.u(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.embedding.android.i.J(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.embedding.android.i.onCreate(Unknown Source:31)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at app.clicksocial.MainActivity.onCreate(Unknown Source:0)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7994)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7978)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:2)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.os.Handler.dispatchMessage(Handler.java:106)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.os.Looper.loop(Looper.java:223)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.ActivityThread.main(ActivityThread.java:7664)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.reflect.Method.invoke(Native Method)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
05-13 02:24:39.241 17891 21072 I HeterodyneSyncScheduler: (REDACTED) Scheduling adaptive one off task with window [%d, %d] in seconds
05-13 02:24:39.241 21090 21090 D StrictMode: StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/view/accessibility/AccessibilityRecord;->getSourceNodeId()J
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.os.StrictMode.lambda$static$1(StrictMode.java:416)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.Class.getDeclaredMethodInternal(Native Method)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.Class.getPublicMethodRecursive(Class.java:2079)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.Class.getMethod(Class.java:2066)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.Class.getMethod(Class.java:1693)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder$b.<init>(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder$b.<init>(SourceFile:2)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder.<init>(Unknown Source:6)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.view.i.<init>(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.embedding.android.B.n(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.embedding.android.j.u(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.embedding.android.i.J(SourceFile:1)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at io.flutter.embedding.android.i.onCreate(Unknown Source:31)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at app.clicksocial.MainActivity.onCreate(Unknown Source:0)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7994)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7978)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:2)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.os.Handler.dispatchMessage(Handler.java:106)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.os.Looper.loop(Looper.java:223)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at android.app.ActivityThread.main(ActivityThread.java:7664)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at java.lang.reflect.Method.invoke(Native Method)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
05-13 02:24:39.241 21090 21090 D StrictMode: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
05-13 02:24:39.242 21090 21090 D StrictMode: StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/view/accessibility/AccessibilityNodeInfo;->mChildNodeIds:Landroid/util/LongArray;
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.os.StrictMode.lambda$static$1(StrictMode.java:416)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at java.lang.Class.getDeclaredField(Native Method)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder$b.<init>(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder$b.<init>(SourceFile:2)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder.<init>(Unknown Source:6)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.view.i.<init>(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.embedding.android.B.n(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.embedding.android.j.u(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.embedding.android.i.J(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.embedding.android.i.onCreate(Unknown Source:31)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at app.clicksocial.MainActivity.onCreate(Unknown Source:0)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7994)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7978)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:2)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.os.Handler.dispatchMessage(Handler.java:106)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.os.Looper.loop(Looper.java:223)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.ActivityThread.main(ActivityThread.java:7664)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at java.lang.reflect.Method.invoke(Native Method)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
05-13 02:24:39.242 21090 21090 D StrictMode: StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/util/LongArray;->get(I)J
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.os.StrictMode.lambda$static$1(StrictMode.java:416)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at java.lang.Class.getDeclaredMethodInternal(Native Method)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at java.lang.Class.getPublicMethodRecursive(Class.java:2079)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at java.lang.Class.getMethod(Class.java:2066)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at java.lang.Class.getMethod(Class.java:1693)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder$b.<init>(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder$b.<init>(SourceFile:2)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.view.AccessibilityViewEmbedder.<init>(Unknown Source:6)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.view.i.<init>(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.embedding.android.B.n(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.embedding.android.j.u(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.embedding.android.i.J(SourceFile:1)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at io.flutter.embedding.android.i.onCreate(Unknown Source:31)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at app.clicksocial.MainActivity.onCreate(Unknown Source:0)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7994)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.Activity.performCreate(Activity.java:7978)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:2)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.os.Handler.dispatchMessage(Handler.java:106)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.os.Looper.loop(Looper.java:223)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at android.app.ActivityThread.main(ActivityThread.java:7664)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at java.lang.reflect.Method.invoke(Native Method)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
05-13 02:24:39.242 21090 21090 D StrictMode: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Flutter Doctor output

Doctor output
% flutter doctor -v                

[✓] Flutter (Channel beta, 3.22.0-0.3.pre, on macOS 14.4.1 23E224 darwin-x64, locale en-US)
    • Flutter version 3.22.0-0.3.pre on channel beta at /Users/luke/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 87b652410d (3 weeks ago), 2024-04-23 21:41:18 -0500
    • Engine revision b4bfd45986
    • Dart version 3.4.0 (build 3.4.0-282.3.beta)
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/luke/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.89.20240501

[✓] Connected device (4 available)
    • iPhone SE (2nd generation) (mobile) • 00008030-000C38343C23402E            • ios            • iOS 17.4.1 21E236
    • iPhone 15 Pro Max (mobile)          • EFA5309D-D65D-4C0C-A589-F1234F7416EE • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)                     • macos                                • darwin-x64     • macOS 14.4.1 23E224 darwin-x64
    • Chrome (web)                        • chrome                               • web-javascript • Google Chrome 124.0.6367.202

[✓] Network resources
    • All expected network resources are available.

• No issues found!
@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label May 14, 2024
@danagbemava-nc
Copy link
Member

Hi @lukehutch, it appears that this warning can be ignored. Please see the links below.

#36915 (comment)
#36915 (comment)

Do they affect your app ?

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 14, 2024
@lukehutch
Copy link
Contributor Author

@danagbemava-nc Thanks for the links. The app is operating OK, but I assumed this was a warning that an API would be locked down in the future against reflection or something, and if the API is not fixed, it will then break (Java did this when they started enforcing strict encapsulation).

Maybe change the text of the error to give a slightly less scary-looking warning, that explains the actual problem?

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 14, 2024
@danagbemava-nc
Copy link
Member

Maybe change the text of the error to give a slightly less scary-looking warning, that explains the actual problem?

This comes from the android system itself so I'm not sure we can modify that warning.

but I assumed this was a warning that an API would be locked down in the future against reflection or something, and if the API is not fixed

My reading of this was, we're using an API that does not come with the sdk itself. I assume the API is still relevant and exists but it is just not packaged with the standard android sdk.

(Java did this when they started enforcing strict encapsulation).

Can you share some links to this? This might be worth looking into further.

Thank you

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 15, 2024
@lukehutch
Copy link
Contributor Author

(Java did this when they started enforcing strict encapsulation).

Can you share some links to this? This might be worth looking into further.

This is for JVM environments, not Dalvik. Strong encapsulation is a feature of the Java module system for JDK 9+, but I'm pretty sure Android isn't using this as a security mechanism, or at least not to report the errors that I reported in this issue.

Here's the link since you asked, even if it's probably not relevant:

https://dev.java/learn/modules/strong-encapsulation/

I'll go ahead and close this since it seems like there's nothing that can be done about this. Thanks!

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 15, 2024
@danagbemava-nc danagbemava-nc added r: solved Issue is closed as solved and removed in triage Presently being triaged by the triage team labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r: solved Issue is closed as solved
Projects
None yet
Development

No branches or pull requests

2 participants