flutter_stripe icon indicating copy to clipboard operation
flutter_stripe copied to clipboard

Unresolved reference: style - CardFormView.kt

Open ambr89 opened this issue 1 year ago • 10 comments

Describe the bug

During the android build I receive an Execution failed:

e: file:///.../.pub-cache/hosted/pub.dev/stripe_android-9.1.0/android/src/main/kotlin/com/reactnativestripesdk/CardFormView.kt:33:71 Unresolved reference: style

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':stripe_android:compileDebugKotlin'.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction Compilation error. See log for more details

To Reproduce I use:

  • Android Studio Flamingo | 2022.2.1
  • Upgrade my main project gradle to 8.0.0 with AGP Tool
  • change build.gradle into stripe_android-9.1.0 package
...
android {
   compileSdkVersion 32
   namespace 'com.flutter.stripe'

   def javaVersion = JavaVersion.VERSION_1_8
   compileOptions {
       sourceCompatibility javaVersion
       sourceCompatibility javaVersion
   }
   kotlinOptions {
       jvmTarget = javaVersion.toString()
   }
...

These changes are needed to try to compile with Flamingo and Java 1.8

I've tried with version 8.0.0+1, 9.0.0+1 and 9.1.0 and always I get this error. Thanks in advance. Ambra

ambr89 avatar Apr 26 '23 12:04 ambr89

Can you provide an example project where this is reproducible?

jonasbark avatar Apr 29 '23 10:04 jonasbark

Hi,

yes you can clone the project from here: https://github.com/ambr89/test_prj

The difference from your documentation is:

in gradle-wrappre.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip

and in android/build.gradle

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.0'   //This move to 8.0.0
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

ambr89 avatar May 02 '23 09:05 ambr89

https://github.com/flutter-stripe/flutter_stripe/pull/1216 was merged - does it help with Gradle 8.0?

jonasbark avatar May 08 '23 09:05 jonasbark

Hi,

no, the error on update 9.2.0 is the same.

e: /Users/ambra/.pub-cache/hosted/pub.dev/stripe_android-9.2.0/android/src/main/kotlin/com/reactnativestripesdk/CardFormView.kt: (33, 71): Unresolved reference: style

FAILURE: Build failed with an exception.

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

ambr89 avatar May 08 '23 09:05 ambr89

Hi,

any news about this?

ambr89 avatar May 16 '23 07:05 ambr89

No news. It's best to use a compatible gradle version for now, if that's the only difference for you.

jonasbark avatar May 16 '23 07:05 jonasbark

Hi,

no problem I've found a solution because I cannot downgrade gradle in my project.

Here there are changes for work with gradle 8.0 and above:

In stripe_android-9.2.0/android/build.gradle

android {
    namespace 'com.flutter.stripe'
    compileSdkVersion 32

   //Add this code block
    def javaVersion = JavaVersion.VERSION_1_8
    compileOptions {
        sourceCompatibility javaVersion
        sourceCompatibility javaVersion
    }
    kotlinOptions {
        jvmTarget = javaVersion.toString()
    }
…

}

in stripe_android-9.2.0/android/src/main/kotline/com/reactnativestripesdk/CardFormView.kt

change this:

internal var cardForm: CardFormView = CardFormView(context, null, R.style.StripeCardFormView_Borderless

with:

internal var cardForm: CardFormView = CardFormView(context)

just with this you can test plugin in debug mode,

for build release apk or appbundle add also this:

In stripe_android-9.2.0/android/proguard-rules.txt

# add this to the end of file
-dontwarn com.google.android.libraries.places.api.Places
-dontwarn com.google.android.libraries.places.api.model.AddressComponent
-dontwarn com.google.android.libraries.places.api.model.AddressComponents
-dontwarn com.google.android.libraries.places.api.model.AutocompletePrediction
-dontwarn com.google.android.libraries.places.api.model.AutocompleteSessionToken
-dontwarn com.google.android.libraries.places.api.model.Place$Field
-dontwarn com.google.android.libraries.places.api.model.Place
-dontwarn com.google.android.libraries.places.api.model.TypeFilter
-dontwarn com.google.android.libraries.places.api.net.FetchPlaceRequest
-dontwarn com.google.android.libraries.places.api.net.FetchPlaceResponse
-dontwarn com.google.android.libraries.places.api.net.FindAutocompletePredictionsRequest$Builder
-dontwarn com.google.android.libraries.places.api.net.FindAutocompletePredictionsRequest
-dontwarn com.google.android.libraries.places.api.net.FindAutocompletePredictionsResponse
-dontwarn com.google.android.libraries.places.api.net.PlacesClient
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivity$g
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider
-dontwarn com.stripe.android.stripecardscan.cardscan.CardScanSheet$CardScanResultCallback
-dontwarn com.stripe.android.stripecardscan.cardscan.CardScanSheet$Companion
-dontwarn com.stripe.android.stripecardscan.cardscan.CardScanSheet
-dontwarn com.stripe.android.stripecardscan.cardscan.CardScanSheetResult$Completed
-dontwarn com.stripe.android.stripecardscan.cardscan.CardScanSheetResult$Failed
-dontwarn com.stripe.android.stripecardscan.cardscan.CardScanSheetResult
-dontwarn com.stripe.android.stripecardscan.cardscan.exception.UnknownScanException
-dontwarn com.stripe.android.stripecardscan.payment.card.ScannedCard

ambr89 avatar May 17 '23 08:05 ambr89

Hi, any news on this issue? I am experiencing the same problem

ilDeffo avatar Jun 20 '23 15:06 ilDeffo

Hi. This is still a problem. Is there any possible update to this? Any work around for CI/CD workflows?

emirua avatar Oct 04 '23 08:10 emirua

Bump. Please include a proguard file for this library for use with R8.

derekpitts28 avatar Oct 13 '23 18:10 derekpitts28

not reproducible anymore

remonh87 avatar Apr 14 '24 15:04 remonh87