WalletConnect / Web3ModalFlutter

The Web3Modal for WalletConnect built using Flutter.
https://pub.dev/packages/web3modal_flutter
Apache License 2.0
44 stars 44 forks source link

Web3Model version 3.2.0 error when building ':package_info_plus:compileReleaseJavaWithJavac'. > error: invalid source release: 17 #130

Closed Luism96xd closed 3 months ago

Luism96xd commented 6 months ago

Describe the bug When I add web3modal_flutter package to my recently created flutter project, I've got this error when I try to run the app on device or building an Android APK.

I tried to change

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

to

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

and the error keeps the same

Steps to reproduce the error:

  1. run flutter pub add web3modal_flutter
  2. set minSdkVersion to 23 in build.gradle.file
  3. flutter build apk

Expected behavior

The flutter app with web3 modal should start and run as the tutorial video. But it does not work, yet

Screenshots

This is the error in my terminal:

screenshot
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.0, on Microsoft Windows [Versi¢n 10.0.19045.4412], locale es-VE)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.7.6)
[√] Android Studio (version 2022.1)
[√] VS Code (version 1.89.1)
[√] Connected device (3 available)
[√] Network resources

Additional context

I followed the following tutorial https://www.youtube.com/watch?v=v_M2buHCpc4 and the Official docs: https://docs.walletconnect.com/web3modal/flutter/installation

I used both versions 3.2.0 (latest) and the same as the video (3.0.20) and nothing worked

I uninstalled all other packages and I haven't written code yet, only installing packages and run

I've got the error in the previous version, too

This is my %JAVA_HOME% variable: C:\Program Files\Java\jdk-19

OS: Windows 10

This is my build.gradle file:

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader("UTF-8") { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
    flutterVersionCode = "1"
}

def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
    flutterVersionName = "1.0"
}

android {
    namespace = "com.example.app"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.app"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdk = 23
        targetSdk = flutter.targetSdkVersion
        versionCode = flutterVersionCode.toInteger()
        versionName = flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig = signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}
quetool commented 6 months ago

Hello @Luism96xd! Can you please revert every change you made and try this? https://github.com/WalletConnect/WalletConnectFlutterV2/issues/290#issuecomment-2118953310

Please run flutter clean and then flutter pub get

Luism96xd commented 6 months ago

Hello @Luism96xd! Can you please revert every change you made and try this? WalletConnect/WalletConnectFlutterV2#290 (comment)

Please run flutter clean and then flutter pub get

Hi! Thanks for answering my issue, so I need to add:

dependencies:
  walletconnect_flutter_v2: ^2.2.3

dependency_overrides:
  package_info_plus: ^8.0.0

then I run flutter clean and flutter pub get

but the error persists if I keep web3modal_flutter package

I'm using web3modal_flutter ^3.2.0 package

That means should I use walletconnect_flutter_v2 package? What's the difference between these two? What are things I can do in web3modal and not in walletconnect_flutter_v2

Do you recommend not using web3modal_flutter until issue is fixed?

quetool commented 6 months ago

Hello @Luism96xd If you use Web3ModalFlutter you don't need WalletConnectFlutterV2

WalletConnectFlutterV2 is the core SDK dependency of Web3ModalFlutter

Where do you set minSdkVersion exactly?

quetool commented 6 months ago

Ah wait I see, you have set minSdk in build.grade but the right key is minSdkVersion so it should be minSdkVersion 23

quetool commented 6 months ago

I only installed web3modal_flutter: 3.2.0 then changed defaultConfig to minSdkVersion 23 and it works fine. Without any other override dependency

Luism96xd commented 6 months ago

I only installed web3modal_flutter: 3.2.0 then changed defaultConfig to minSdkVersion 23 and it works fine. Without any other override dependency

Ah wait I see, you have set minSdk in build.grade but the right key is minSdkVersion so it should be minSdkVersion 23

Thanks for researching, I'm using Flutter 3.22 and when we generate a new project the keys are minSdk and this flutter version and previous one give me this error:

':package_info_plus:compileReleaseJavaWithJavac'. > error: invalid source release: 17

The error persist, with or without dependency override, with minSdk or minSdkVersion, which flutter version are you using?

Thanks in advance

quetool commented 5 months ago

Hello @Luism96xd ! Sorry for the late response. Do you still need help here?