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

Update the Android project #30

Merged

Conversation

Abestanis
Copy link
Collaborator

I created a new flutter project and merged the new Android project template into the current one.

This has the following side effects:

  • The way the status bar color is applied during the splash screen are improved:

    Before After
    Startup - Before Startup - After
  • The application and services are now marked with the exported attribute, This will be required for Android API 31.

I was also planning to bring the target sdk version from 30 to Flutters default, 31. But we need to update our audioservice dependency first, because it creates a PendingIntent without specifying FLAG_IMMUTABLE. See the documentation and

the stack trace
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.nt4f04und.sweyer, PID: 23585
    java.lang.RuntimeException: Unable to create service com.ryanheise.audioservice.AudioService: java.lang.IllegalArgumentException: com.nt4f04und.sweyer: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:4518)
        at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2153)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7844)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
     Caused by: java.lang.IllegalArgumentException: com.nt4f04und.sweyer: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:401)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:671)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:658)
        at android.support.v4.media.session.MediaSessionCompat.<init>(MediaSessionCompat.java:557)
        at android.support.v4.media.session.MediaSessionCompat.<init>(MediaSessionCompat.java:528)
        at android.support.v4.media.session.MediaSessionCompat.<init>(MediaSessionCompat.java:492)
        at android.support.v4.media.session.MediaSessionCompat.<init>(MediaSessionCompat.java:466)
        at com.ryanheise.audioservice.AudioService.onCreate(AudioService.java:344)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:4505)
        	... 9 more

We could also use this opportunity to update our dependencies, like com.google.firebase, but I cant really test them easily, so I would leave that to you.

Copy link
Owner

@nt4f04uNd nt4f04uNd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small comments

I verified it and it definitely improves the splash screen - I was really lost in the past trying to find a configuration that would work like this one

Thank you for that!

android/.gitignore Outdated Show resolved Hide resolved
android/app/build.gradle Show resolved Hide resolved
android/app/build.gradle Show resolved Hide resolved
android/app/src/main/AndroidManifest.xml Outdated Show resolved Hide resolved
android/app/src/main/AndroidManifest.xml Outdated Show resolved Hide resolved
This also improves the way the status bar color is applied during the
splash screen. Additional, the application and services are now
marked with the "exported" attribute.
@Abestanis Abestanis force-pushed the feature/android_project_upgrade branch from 5abb58d to 1a2adb0 Compare May 11, 2022 19:39
@Abestanis
Copy link
Collaborator Author

I merged the .gitignore and re-added the commented elements in AndroidManifest.xml.

Copy link
Owner

@nt4f04uNd nt4f04uNd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks!

@nt4f04uNd nt4f04uNd merged commit 4054178 into nt4f04uNd:1.0.8 May 11, 2022
@Abestanis Abestanis deleted the feature/android_project_upgrade branch May 11, 2022 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants