square / in-app-payments-flutter-plugin

Flutter Plugin for Square In-App Payments SDK
https://developer.squareup.com/docs
Apache License 2.0
340 stars 121 forks source link

Error when adding the plugin to the project #183

Closed IosefSaiegh closed 2 years ago

IosefSaiegh commented 2 years ago

Describe the issue

I'm trying to add the plugin to my flutter project, but when I run the app I get this in the console:

  Launching lib\main.dart on Android SDK built for x86 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform moshi-1.13.0.jar (com.squareup.moshi:moshi:1.13.0) to match attributes {artifactType=android-java-res, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for JetifyTransform: C:\Users\Iosef\.gradle\caches\modules-2\files-2.1\com.squareup.moshi\moshi\1.13.0\da685586facab9eb5c4fb630ce248be14e7da21b\moshi-1.13.0.jar.
         > Failed to transform 'C:\Users\Iosef\.gradle\caches\modules-2\files-2.1\com.squareup.moshi\moshi\1.13.0\da685586facab9eb5c4fb630ce248be14e7da21b\moshi-1.13.0.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 60. (Run with --stacktrace for more details.)
           Suggestions:
            - Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
            - If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
* 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 16s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Environment (please complete the following information):

[√] Flutter (Channel stable, 2.10.4, on Microsoft Windows [Versiֳ³n 10.0.19043.1586], locale es-AR) • Flutter version 2.10.4 at C:\src\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision c860cba910 (12 days ago), 2022-03-25 00:23:12 -0500 • Engine revision 57d3bac3dd • Dart version 2.16.2 • DevTools version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Iosef\AppData\Local\Android\sdk • Platform android-31, build-tools 30.0.3 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.10.4) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.10.31515.178 • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)

[√] VS Code (version 1.66.0) • VS Code at C:\Users\Iosef\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.38.1

[√] Connected device (4 available) • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Versiֳ³n 10.0.19043.1586] • Chrome (web) • chrome • web-javascript • Google Chrome 99.0.4844.84 • Edge (web) • edge • web-javascript • Microsoft Edge 99.0.1150.55

[√] HTTP Host Availability • All required HTTP hosts are available

• No issues found!

ElAdrixHD commented 2 years ago

Add this 3 lines in android/gradle.properties :

android.proguard.enableRulesExtraction=false
android.jetifier.ignorelist=moshi-1.13.0
android.jetifier.blacklist=moshi-1.13.0
IosefSaiegh commented 2 years ago

now another error appears: Launching lib\main.dart on Android SDK built for x86 in debug mode...

FAILURE: Build failed with an exception.

BUILD FAILED in 6m 24s Exception: Gradle task assembleDebug failed with exit code 1 Exited (sigterm)

ElAdrixHD commented 2 years ago

https://stackoverflow.com/questions/67651574/android-build-error-execution-failed-for-task-appcheckdebugduplicateclasses

You have both mavenCentral and jcenter as repositories. Remove jcenter() from your project gradle file since it is already obsolete.

IosefSaiegh commented 2 years ago

I keep getting the same error

KejariwalAyush commented 2 years ago

I am also facing the same issue

KejariwalAyush commented 2 years ago

Ok so i got the fix for this after going though the example app

thats it! It worked like a charm for me.

CharmisG commented 2 years ago

Resolved in latest update.