mateusfccp / update_available

Know if there's any update for your Flutter app, based on published versions.
MIT License
25 stars 16 forks source link

jvm target incompatibility #43

Open SpirikleOfficial opened 3 months ago

SpirikleOfficial commented 3 months ago

Getting this error:

Execution failed for task ':update_available_android:compileDebugKotlin'.

'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.

if we have in android/settings.gradle the following config then it works:

    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.0" apply false
    id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

but if the above are changed to:

    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.0.2" apply false
    id "org.jetbrains.kotlin.android" version "1.9.0" apply false
}

then the error is recieved.

update_available version: 3.1.0+1

mateusfccp commented 3 months ago

Thank you for your report.

Can you provide a minimal reproduction sample?

SpirikleOfficial commented 3 months ago

Open the default flutter project and add the lines mentioned previously. Also in the gradle-wrapper.properties file change the distributionURL to:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip

The above changes gave us the error.

mateusfccp commented 3 months ago

Open the default flutter project and add the lines mentioned previously. Also in the gradle-wrapper.properties file change the distributionURL to:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip

The above changes gave us the error.

What version of Flutter are you using? Did it used to work in previous versions?

SpirikleOfficial commented 3 months ago

Yes it did used to work previously. It seems the flutter version is not the culprit but the gradle versions are. As we tried to run on latest flutter default project and there it ran perfectly but with old gradle versions.

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.24.1, on Microsoft Windows [Version 10.0.22631.4037], locale en-CA)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.1)
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.89.1)
[√] Connected device (3 available)
[√] Network resources
SpirikleOfficial commented 2 months ago

any update on how long this is going to take? We need to use it before 29 Aug.

mateusfccp commented 2 months ago

any update on how long this is going to take? We need to use it before 29 Aug.

Hello, @SpirikleOfficial.

Could you open a PR with a fix?

I'm not sure I'll be able to do it myself before tomorrow, as I'm a little busy this week, but I could definitely review your PR.

mateusfccp commented 2 months ago

@SpirikleOfficial Can you test against master? I just committed a potential solution.

In my personal tests, it should now emit a warning but compile nonetheless.

SpirikleOfficial commented 2 months ago

Will check and let you know

mateusfccp commented 2 months ago

@SpirikleOfficial I don't want to bother you, but could you test it?

I want to release a new version after this has been solved.

SpirikleOfficial commented 2 months ago

Used this in our pubspec.yaml:

dependency_overrides:
  update_available:
    git:
      url: https://github.com/mateusfccp/update_available
      ref: master
      path: update_available
  update_available_ios:
    git:
      url: https://github.com/mateusfccp/update_available
      ref: master
      path: update_available_ios
  update_available_android:
    git:
      url: https://github.com/mateusfccp/update_available
      ref: master
      path: update_available_android

Compiled with success. However, our debug app had old version and Google play store shows update available but we are getting UnknownAvailability() everytime. The same code worked previously when your package was able to compile but not now. The code is:

 final updateAvailability = await getUpdateAvailability();
    switch (updateAvailability) {
      case UpdateAvailable():
        {
          print('update available');
        }
      case NoUpdateAvailable():
        {

          print('no update available');
        }
      case UnknownAvailability():
        {
          print('unknown update available');
        }
    }

Are we doing something wrong in our code or there is a problem in the package?

mateusfccp commented 2 months ago

@SpirikleOfficial

That's interesting (and weird).

Does anything appear in the Java logs?

SpirikleOfficial commented 2 months ago

These are the logs after the getUpdateAvailablity() is called:

I/PlayCore(18318): UID: [10926]  PID: [18318] AppUpdateService : requestUpdateInfo(com.spirikle.scanclan)
I/PlayCore(18318): UID: [10926]  PID: [18318] AppUpdateService : Initiate binding to the service.
W/System  (18318): Ignoring header X-Firebase-Locale because its value was null.
I/PlayCore(18318): UID: [10926]  PID: [18318] AppUpdateService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.installservice.DevTriggeredUpdateService})
I/PlayCore(18318): UID: [10926]  PID: [18318] AppUpdateService : linkToDeath
W/DynamiteModule(18318): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule(18318): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller(18318): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
D/TrafficStats(18318): tagSocket(123) with statsTag=0xffffffff, statsUid=-1
W/ProviderInstaller(18318): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]
I/irikle.scanclan(18318): Waiting for a blocking GC ClassLinker
I/irikle.scanclan(18318): WaitForGcToComplete blocked ClassLinker on NativeAlloc for 47.732ms
V/NativeCrypto(18318): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 305 native methods...
W/irikle.scanclan(18318): Accessing hidden method Ldalvik/system/VMStack;->getStackClass2()Ljava/lang/Class; (unsupported, reflection, allowed)
W/irikle.scanclan(18318): Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (unsupported, reflection, allowed)
I/ProviderInstaller(18318): Installed default security provider GmsCore_OpenSSL
W/OnBackInvokedCallback(18318): OnBackInvokedCallback is not enabled for the application.
W/OnBackInvokedCallback(18318): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
D/TrafficStats(18318): tagSocket(265) with statsTag=0xffffffff, statsUid=-1
I/PlayCore(18318): UID: [10926]  PID: [18318] OnRequestInstallCallback : onRequestInfo
I/PlayCore(18318): UID: [10926]  PID: [18318] AppUpdateService : Unbind from service.
W/irikle.scanclan(18318): Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (unsupported, reflection, allowed)
mateusfccp commented 2 months ago

UnknownAvailability means specifically that something happened that prevented the plugin from discovering the availability, probably an error.

It's weird that it didn't happen before and is happening now.

The log doesn't show anything relevant.

mateusfccp commented 2 months ago

@SpirikleOfficial

Please, update your code to the latest master.

I exposed the PlatformException from the method channel to the UnknownAvailability object.

Please, test your code again and check whether the error and stackTrace object are non-null. They may give us more insight about what's happening.

SpirikleOfficial commented 2 months ago

after running pub get:

! update_available 3.1.0 from git https://github.com/mateusfccp/update_available at d46125 in update_available (overridden)
! update_available_android 3.1.0 from git https://github.com/mateusfccp/update_available at d46125 in update_available_android (overridden)
! update_available_ios 3.1.0 from git https://github.com/mateusfccp/update_available at d46125 in update_available_ios (overridden)
+ update_available_platform_interface 4.0.1

Not able to compile:

../../AppData/Local/Pub/Cache/git/update_available-d46125c3cd537c1a1f45d179e0669c170a56d365/update_available_android/lib/update_available_android.dart:25:9: Error: No named parameter with the name 'error'.
        error: error,
        ^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dev/update_available_platform_interface-4.0.1/lib/src/availability.dart:28:9: Context: Found this candidate, but the arguments don't match.
  const UnknownAvailability();
        ^^^^^^^^^^^^^^^^^^^
Target kernel_snapshot_program failed: Exception
mateusfccp commented 2 months ago

Right, I forgot about pubspec_overrides.

mateusfccp commented 2 months ago

I just released 3.2.0-dev.1. Can you test against it?

SpirikleOfficial commented 2 months ago

pub get:

! update_available 3.1.0 from git https://github.com/mateusfccp/update_available at b1c960 in update_available (overridden)
! update_available_android 3.1.0 from git https://github.com/mateusfccp/update_available at b1c960 in update_available_android (overridden)
! update_available_ios 3.1.0 from git https://github.com/mateusfccp/update_available at b1c960 in update_available_ios (overridden)

no compilation as before:

../../AppData/Local/Pub/Cache/git/update_available-b1c960ba037824afacdaabf91ee70a8c0186b6ad/update_available_android/lib/update_available_android.dart:25:9: Error: No named parameter with the name 'error'.
        error: error,
        ^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dev/update_available_platform_interface-4.0.1/lib/src/availability.dart:28:9: Context: Found this candidate, but the arguments don't match.
  const UnknownAvailability();
        ^^^^^^^^^^^^^^^^^^^
Target kernel_snapshot_program failed: Exception
mateusfccp commented 2 months ago

pub get:

! update_available 3.1.0 from git https://github.com/mateusfccp/update_available at b1c960 in update_available (overridden)
! update_available_android 3.1.0 from git https://github.com/mateusfccp/update_available at b1c960 in update_available_android (overridden)
! update_available_ios 3.1.0 from git https://github.com/mateusfccp/update_available at b1c960 in update_available_ios (overridden)

no compilation as before:

../../AppData/Local/Pub/Cache/git/update_available-b1c960ba037824afacdaabf91ee70a8c0186b6ad/update_available_android/lib/update_available_android.dart:25:9: Error: No named parameter with the name 'error'.
        error: error,
        ^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dev/update_available_platform_interface-4.0.1/lib/src/availability.dart:28:9: Context: Found this candidate, but the arguments don't match.
  const UnknownAvailability();
        ^^^^^^^^^^^^^^^^^^^
Target kernel_snapshot_program failed: Exception

Your packages are wrong for some reason.

update_available_platform_interface should be 4.1.0-dev.1 instead of 4.0.1.

Are you sure you removed all overrides?

SpirikleOfficial commented 2 months ago

Please tell the code to write in pubspec.yaml

mateusfccp commented 2 months ago
dependencies:
  update_available: 3.2.0-dev.1

You shouldn't have anything related to update_available in dependency_overrides.

SpirikleOfficial commented 2 months ago

Got it. Below is the console output:

I/PlayCore(12753): UID: [10926]  PID: [12753] AppUpdateService : requestUpdateInfo(com.spirikle.scanclan)
I/PlayCore(12753): UID: [10926]  PID: [12753] AppUpdateService : Initiate binding to the service.
I/PlayCore(12753): UID: [10926]  PID: [12753] AppUpdateService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.installservice.DevTriggeredUpdateService})
I/PlayCore(12753): UID: [10926]  PID: [12753] AppUpdateService : linkToDeath
W/DynamiteModule(12753): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/PlayCore(12753): UID: [10926]  PID: [12753] OnRequestInstallCallback : onRequestInfo
I/PlayCore(12753): UID: [10926]  PID: [12753] AppUpdateService : Unbind from service.
I/DynamiteModule(12753): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller(12753): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
W/ProviderInstaller(12753): Failed to report request stats: com.google.android.gms.common.security.ProviderInstallerImpl.reportRequestStats [class android.content.Context, long, long]
V/NativeCrypto(12753): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 305 native methods...
W/irikle.scanclan(12753): Accessing hidden method Ldalvik/system/VMStack;->getStackClass2()Ljava/lang/Class; (unsupported, reflection, allowed)
W/irikle.scanclan(12753): Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (unsupported, reflection, allowed)
I/ProviderInstaller(12753): Installed default security provider GmsCore_OpenSSL
W/OnBackInvokedCallback(12753): OnBackInvokedCallback is not enabled for the application.
W/OnBackInvokedCallback(12753): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
mateusfccp commented 2 months ago

Can you see if any error is returned in the UnknownAvailability object?

Notice that now it has two fields, error and stackTrace. They should have a PlatformException and it's exception.

SpirikleOfficial commented 2 months ago

used this code:

 case UnknownAvailability():
        {
          print(
              'error from updateAvailability object: ${updateAvailability.error}');
          print(
              'stackTrace from updateAvailability object: ${updateAvailability.stackTrace}');
        }

Output:

I/PlayCore(30456): UID: [10926]  PID: [30456] AppUpdateService : requestUpdateInfo(com.spirikle.scanclan)
I/PlayCore(30456): UID: [10926]  PID: [30456] AppUpdateService : Initiate binding to the service.
I/PlayCore(30456): UID: [10926]  PID: [30456] AppUpdateService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.installservice.DevTriggeredUpdateService})
I/PlayCore(30456): UID: [10926]  PID: [30456] AppUpdateService : linkToDeath
I/PlayCore(30456): UID: [10926]  PID: [30456] OnRequestInstallCallback : onRequestInfo
I/PlayCore(30456): UID: [10926]  PID: [30456] AppUpdateService : Unbind from service.
W/OnBackInvokedCallback(30456): OnBackInvokedCallback is not enabled for the application.
W/OnBackInvokedCallback(30456): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
I/flutter (30456): error from updateAvailability object: PlatformException(INITIALIZATION_FAILURE, Failed to get appUpdateInfoTask, null, null)
I/flutter (30456): stackTrace from updateAvailability object: #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
I/flutter (30456): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
I/flutter (30456): <asynchronous suspension>
I/flutter (30456): #2      UpdateAvailableAndroidPlugin.getUpdateAvailability (package:update_available_android/update_available_android.dart:16:25)
I/flutter (30456): <asynchronous suspension>
I/flutter (30456): #3      _HomeScreenState.checkUpdate (package:scanclan/screens/home_screen.dart:309:32)
I/flutter (30456): <asynchronous suspension>
mateusfccp commented 2 months ago

Can you try these solutions?

pro100svitlo commented 3 weeks ago

Hi guys, any update on this issue? I am facing the same one

mateusfccp commented 3 weeks ago

@pro100svitlo I can't reproduce with the example.

If you can reproduce the problem with the example or provide a PR, I would gladly review it.