update_available icon indicating copy to clipboard operation
update_available copied to clipboard

jvm target incompatibility

Open SpirikleOfficial opened this issue 1 year ago • 25 comments

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

SpirikleOfficial avatar Aug 25 '24 13:08 SpirikleOfficial

Thank you for your report.

Can you provide a minimal reproduction sample?

mateusfccp avatar Aug 25 '24 13:08 mateusfccp

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.

SpirikleOfficial avatar Aug 25 '24 13:08 SpirikleOfficial

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?

mateusfccp avatar Aug 25 '24 21:08 mateusfccp

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 avatar Aug 26 '24 09:08 SpirikleOfficial

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

SpirikleOfficial avatar Aug 28 '24 07:08 SpirikleOfficial

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 avatar Aug 28 '24 11:08 mateusfccp

@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.

mateusfccp avatar Aug 29 '24 13:08 mateusfccp

Will check and let you know

SpirikleOfficial avatar Aug 31 '24 02:08 SpirikleOfficial

@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.

mateusfccp avatar Sep 09 '24 13:09 mateusfccp

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?

SpirikleOfficial avatar Sep 10 '24 03:09 SpirikleOfficial

@SpirikleOfficial

That's interesting (and weird).

Does anything appear in the Java logs?

mateusfccp avatar Sep 10 '24 23:09 mateusfccp

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)

SpirikleOfficial avatar Sep 11 '24 07:09 SpirikleOfficial

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 avatar Sep 11 '24 11:09 mateusfccp

@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.

mateusfccp avatar Sep 11 '24 12:09 mateusfccp

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

SpirikleOfficial avatar Sep 11 '24 15:09 SpirikleOfficial

Right, I forgot about pubspec_overrides.

mateusfccp avatar Sep 11 '24 17:09 mateusfccp

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

mateusfccp avatar Sep 11 '24 17:09 mateusfccp

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

SpirikleOfficial avatar Sep 12 '24 06:09 SpirikleOfficial

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?

mateusfccp avatar Sep 12 '24 09:09 mateusfccp

Please tell the code to write in pubspec.yaml

SpirikleOfficial avatar Sep 12 '24 10:09 SpirikleOfficial

dependencies:
  update_available: 3.2.0-dev.1

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

mateusfccp avatar Sep 12 '24 14:09 mateusfccp

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.

SpirikleOfficial avatar Sep 13 '24 05:09 SpirikleOfficial

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.

mateusfccp avatar Sep 13 '24 10:09 mateusfccp

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>

SpirikleOfficial avatar Sep 13 '24 11:09 SpirikleOfficial

Can you try these solutions?

  • https://stackoverflow.com/questions/56581300/android-in-app-updates-not-able-to-detect-the-update-in-appupdateinfo
  • https://stackoverflow.com/questions/63956696/flutter-appupdateservice-linktodeath

mateusfccp avatar Sep 13 '24 17:09 mateusfccp

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

pro100svitlo avatar Oct 30 '24 18:10 pro100svitlo

@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.

mateusfccp avatar Oct 30 '24 19:10 mateusfccp

@mateusfccp this issue can be fixed by adding JVM toolchain configuration to use version 17 in kotlin closure in build.gradle file. I have created a PR for the same. #48 , please review.

SushantSangle avatar Jan 21 '25 11:01 SushantSangle

This was (probably) solved by #48 and is available on master.

I will make a release with this fix. If anyone find any regression caused by this, please, reach out as soon as possible so I can revert the fix.

(I couldn't test it because I couldn't reproduce the issue, and there's no tests for this, so I'm a little aprehensive, but I'm trusting @SushantSangle's great work for this. Also, I'm not using this package anywhere, so I depend on you guys to know if anything happens.)

mateusfccp avatar Jan 23 '25 11:01 mateusfccp