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

https://github.com/fluttercommunity/wakelock_plus/commit/847f3171916c9237fcf885039d4a0c9079430f83 #48

Open
syleishere opened this issue Apr 16, 2024 · 22 comments

Comments

@syleishere
Copy link

This is breaking flet's video plugin with following:

compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
The class is loaded from C:/Users/dan/.gradle/caches/transforms-3/6498ee1438a7a83cb4725beb055db98c/transformed/jetified-kotlin-stdlib-1.9.23.jar!/kotlin/Unit.class
e: C:\Users\dan\AppData\Local\Pub\Cache\hosted\pub.dev\wakelock_plus-1.2.1\android\src\main\kotlin\dev\fluttercommunity\plus\wakelock\WakelockPlusPlugin.kt: (38, 5): Class 'kotlin.Unit' was
compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
The class is loaded from C:/Users/dan/.gradle/caches/transforms-3/6498ee1438a7a83cb4725beb055db98c/transformed/jetified-kotlin-stdlib-1.9.23.jar!/kotlin/Unit.class
e: C:\Users\dan\AppData\Local\Pub\Cache\hosted\pub.dev\wakelock_plus-1.2.1\android\src\main\kotlin\dev\fluttercommunity\plus\wakelock\WakelockPlusPlugin.kt: (42, 16): Class 'kotlin.Unit' was
compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
The class is loaded from C:/Users/dan/.gradle/caches/transforms-3/6498ee1438a7a83cb4725beb055db98c/transformed/jetified-kotlin-stdlib-1.9.23.jar!/kotlin/Unit.class

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':wakelock_plus:compileReleaseKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 28s
Gradle task assembleRelease failed with exit code 1

Error building Flet app - see the log of failed command above.
PS C:\Users\dan\flet\crystaltunes> flutter pub upgrade
Expected to find project root in current working directory.
PS C:\Users\dan\flet\crystaltunes> cd ..
PS C:\Users\dan\flet> flutter pub upgrade
Expected to find project root in current working directory.
PS C:\Users\dan\flet>

At least for version 1.2.1 that video currently uses. We have no control over running flutter pub upgrades etc on a flet build, the commit essentially breaks the complete package when I try to include video plugin as media_kit includes this in it's own dependencies.

@diegotori
Copy link
Collaborator

@syleishere you have to run flutter pub upgrade on your own project. Also, please ensure that the dependency isn't pinning version 1.2.1 (in other words declaring that version without a ^.

Lastly, you may have to force 1.2.4 by way of dependency_overrides in your pubspec.

@syleishere
Copy link
Author

The issue is this is not a flutter project, it is a flet project. Flet will go off and build this in a temporary directory, if I could override this in pubspec with a normal flutter project I would :). This was working fine compiling for me for months, then last couple of weeks I figured because of android studio upgrade of kotlin that was the problem, but when I saw this commit I realized this is what has been breaking it for weeks now...

@diegotori
Copy link
Collaborator

The issue is this is not a flutter project, it is a flet project. Flet will go off and build this in a temporary directory, if I could override this in pubspec with a normal flutter project I would :). This was working fine compiling for me for months, then last couple of weeks I figured because of android studio upgrade of kotlin that was the problem, but when I saw this commit I realized this is what has been breaking it for weeks now...

Unfortunately, you'll have to take it up with the flet folks.

Right now, they are declaring media_kit as a dependency, and that library is using a pre 1.2.x version of this library.

One solution is to have flet add a dependency override for this version. Another is to submit a PR for media_kit that upgrades wakelock_plus to the latest version.

@syleishere
Copy link
Author

Sadly I've done both in different threads on both of those projects, media_kit seems inactive for last 5 months, flet's developers busy on building an official release of flet for the year, now I've posted to all 3 projects and my project still remains broken :(

@syleishere
Copy link
Author

Why downgrade kotlin to begin with? People upgrade android studio, it should work with current kotlin

@syleishere
Copy link
Author

Actually maybe I can override C:\Users\dan\AppData\Local\Pub\Cache\hosted\pub.dev\wakelock_plus-1.2.1\ in manually from error messages not sure...

@diegotori
Copy link
Collaborator

Actually maybe I can override C:\Users\dan\AppData\Local\Pub\Cache\hosted\pub.dev\wakelock_plus-1.2.1\ in manually from error messages not sure...

You can try blasting your pub cache if all else fails.

@syleishere
Copy link
Author

Yeah won't matter, I did a fresh install of windows 11 on my laptop last night hoping I could with a fresh install have older version of kotlin, got same error. All this started when I had an older flutter project I loaded in android studio that asked me to upgrade the gradle, and boom flet project went booom

@diegotori
Copy link
Collaborator

Yeah won't matter, I did a fresh install of windows 11 on my laptop last night hoping I could with a fresh install have older version of kotlin, got same error. All this started when I had an older flutter project I loaded in android studio that asked me to upgrade the gradle, and boom flet project went booom

Another thing that you can do is upgrade the Android SDK and create a dummy flutter project that uses wakelock plus and then run flutter pub upgrade.

Otherwise, flet should be modified so that it performs a flutter pub upgrade on the project that it creates.

@syleishere
Copy link
Author

hmm that's a great idea I'll give it a shot

@syleishere
Copy link
Author

wsl:/mnt/c/Users/dan/AppData/Local/Pub/Cache/hosted/pub.dev # find media_kit*|grep pubspec |xargs cat|grep wakelock
  wakelock_plus: ^1.1.1
wsl:/mnt/c/Users/dan/AppData/Local/Pub/Cache/hosted/pub.dev #

Strange thing here is it downloads 1.2.1 when set to 1.1.1 upgradeable. I tried what you said create flutter project with 1.2.4, that downloaded it, but it still used 1.2.1. So I nuked 1.2.1 and replaced directory with 1.2.4 and build failed same way...

@diegotori
Copy link
Collaborator

Then the generated project from flet needs to either use a dependency override, or flutter pub upgrade must be called prior to building.

The former might be the solution that will work more effectively to be honest. If you can isolate the temporary project and manually add the dependency override, that might force it to use that version.

You'll have to reach out to the folks at flet so that they can add the ability to customize the pubspec for situations such as this one.

@syleishere
Copy link
Author

syleishere commented Apr 16, 2024

hmm interesting: when forcing it in media_kit:

Generating app icons...Because serious_python >=0.7.0 depends on serious_python_platform_interface ^0.7.0 which depends on package_info_plus ^4.2.0, serious_python >=0.7.0 requires package_info_plus ^4.2.0.
And because wakelock_plus >=1.2.4 depends on package_info_plus >=6.0.0 <8.0.0, serious_python >=0.7.0 is incompatible with wakelock_plus >=1.2.4.
And because every version of flet_video depends on media_kit_video ^1.2.4 which depends on wakelock_plus ^1.2.4, serious_python >=0.7.0 is incompatible with flet_video.
So, because crystaltunes depends on both flet_video any and serious_python ^0.7.0, version solving failed.


You can try the following suggestion to make the pubspec resolve:
* Consider downgrading your constraint on serious_python: dart pub add serious_python:^0.1.5

Error building Flet app - see the log of failed command above.
PS C:\Users\dan\flet\crystaltunes>

Hmm interesting, having more of a look.....

@diegotori
Copy link
Collaborator

You'll have to also force package_info_plus as well to at least version 6.0.0.

The long term solution is to submit a PR that updates media_kit to use the latest wakelock plus version.

@syleishere
Copy link
Author

media-kit/media-kit#771
I don't think they responding to any issues it seems.

as well as:
flet-dev/flet#2968
from another user

All this happening because of gradle upgrade in kotlin lol.

Maybe best solution is try to rollback to a previous android studio version till all this is resolved, but I am unsure how to downgrade kotlin, I've played with all the options nothing seems to work :(

@syleishere
Copy link
Author

Well I forced package_info_plus, and that did the trick, compiles, so forcing newest wakelock_plus as well as package_info_plus did the trick. I much appreciate your time today, I'll submit a PR to flet github with fixes needed.

@syleishere
Copy link
Author

I have tested your plugin so far on web, and works wonderfully btw :) I'll test on android in a bit, but a bit concerned with new issues around google, without issuing foreground service calls, wakelock may not work soon they have stated on newer APIs, along with needing a youtube video to show off app before being allowed. I am not sure if your plugin does foreground service request on android with new needed format.....

@diegotori
Copy link
Collaborator

diegotori commented Apr 16, 2024

As far as Android is concerned, the plugin merely keeps the screen on through the Activity's WindowManager, adding or removing WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON. Nothing more, nothing less.

Based on the current docs, it doesn't look like that flag isn't going away anytime soon. I could be mistaken though.

Anything beyond that (i.e. CPU wakelocks) are beyond the scope of this library.

@syleishere
Copy link
Author

Tested on android as an app and in chrome browser on android accessing app remotely. With chrome version. I can shut screen off and still plays music endlessly which is great, even adds something to shut off screen what remote url it is playing.

As an app, does keep screen on, but when I shut off screen, music plays for a few minutes at best then shuts off. Curious if anything can do here...

@syleishere
Copy link
Author

syleishere commented Apr 16, 2024

I decided to move to python because of AI aspects, and always hated working with spaghetti flutter code. Plus now that mojo has been made open source, won't be long before python runs faster than c++ and rust

@FeodorFitsner
Copy link

It's fixed now in Flet 0.23. Sorry it took so long.

@FeodorFitsner
Copy link

@diegotori Thanks for your help here 🙏🏻 - really appreciate your timely responses though it's Flet's issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants