#thiago-android-terminal

1 messages ยท Page 1 of 1 (latest)

grim harbor
#

hello, not sure off the top of my head but that sounds like a dependency issue, so lets start here

what stripe-terminal-android version do you have installed

strong orchid
#

thanks a lot!

#

implementation "com.stripe:stripeterminal:2.2.0"

#

when i use "internet" config

#

works like a charm

#

any idea?

grim harbor
strong orchid
#

let me try

#

the same :/

river bison
#

๐Ÿ‘‹ @grim harbor had to leave, but I'm stepping in!

#

Just to make sure I understand everything correctly - what specifically are you doing differently in the "internet" config so that it works?

strong orchid
#

one sec

#

val config = DiscoveryConfiguration(0, DiscoveryMethod.INTERNET, true) -> WORKS
val config = DiscoveryConfiguration(10, DiscoveryMethod.BLUETOOTH_SCAN, false) -> not work

river bison
#

thanks for that - let me dig a bit more

strong orchid
#

thanks @river bison

river bison
#

I'm not seeing any reason why this shouldn't work... can you try forcing an update to refresh the dependencies? I wonder if somethign is still out of sync

strong orchid
#

What dependencies?

#

I already set the terminal to the last one

grim harbor
#

a couple of us are catching up, give us a second

#

karbi had to step away

strong orchid
#

thanks!

mystic ermine
strong orchid
#

1 min

#

any ideas before that? because I'll need to update my gradle to version 7

#

and right now it wasn't the idea

grim harbor
#

give me a sec to quickly repro this, one min

strong orchid
#

thanks @grim harbor

grim harbor
#

@strong orchid mind pasting the full import for BluetoothReaderListener that you're declaring in your Kotlin/Java file?

river bison
#

Feel free to continue here @strong orchid

strong orchid
#

@grim harbor do you mean about the #imports?

river bison
#

Yes, he's asking for the full import line for BluetoothReaderListener

strong orchid
#

Give me one min

#

It's weird, i don't have any imports for that

#

๐Ÿ˜

#

Did i need any import?

strong orchid
#

these are my imports

#

import android.os.Bundle
import android.os.Handler
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import com.stripe.stripeterminal.Terminal
import com.stripe.stripeterminal.external.callable.*
import com.stripe.stripeterminal.external.models.*
import ironark.com.charge.R
import ironark.com.charge.activities.MainActivity
import ironark.com.charge.adapters.ReaderLocationsAdapter
import ironark.com.charge.api.StripeTerminalApplication.Companion.readerSelected
import ironark.com.charge.database.PrefsModels
import ironark.com.charge.database.PrefsModels.connectedReaderLocId
import ironark.com.charge.database.PrefsModels.connectedReaderSn
import ironark.com.charge.utils.StripeTerminalManager
import kotlinx.android.synthetic.main.fragment_reader_locations.*
import org.jetbrains.anko.*
import org.jetbrains.anko.support.v4.act
import org.jetbrains.anko.support.v4.ctx
import org.jetbrains.anko.support.v4.runOnUiThread
import org.jetbrains.anko.support.v4.toast

strong orchid
#

just added this one import com.stripe.stripeterminal.external.callable.BluetoothReaderListener

#

and nothing

strong orchid
#

any idea?

tribal anvil
#

Catching up on this thread. One minute...

strong orchid
#

thanks @tribal anvil

grim harbor
#

where do you get this error @strong orchid , like can you share a screenshot of your Android Studio when you get this error?

#

to give you more context - a few of us tried a fresh project, integrated the stripe-terminal-android SDK from scratch and synced gradle and had no build or dependency issues. So we couldn't repro, so trying to get as much info from your dev/Android Studio set up to see what is different

strong orchid
#

when I'm trying to connect to reader

#

Terminal.getInstance().connectBluetoothReader(reader, connectionConfig, activity?.get(), object : ReaderCallback {ReaderCallback {
override fun onSuccess(reader: Reader) {
mOnStripeTerminalListener.connectBluetoothReader(reader)
}
override fun onFailure(e: TerminalException) {
e.printStackTrace()
mOnStripeTerminalListener.connectBluetoothReader(reader, e.errorMessage)
}
})

#

when I was testing by internertConfig -> // Terminal.getInstance().connectInternetReader(reader, connectionConfig, object : ReaderCallback {

#

works

grim harbor
#

in a pastebin, can you paste me the full activity where you implement BluetoothReaderListener?

#

and in the meantime, looking cause I haven't encountered this issue before (nothing reported on the github issues either)

strong orchid
#

yep

#

I also didn't find anything reported on the gitub

grim harbor
#

@strong orchid
what exact line does it crash on, is it sometime after it calls connectBluetoothReader() ? Or immediately on that line?

strong orchid
#

It's not a crash, just an error when call this function

#

line 193 call this function

#

fun connectBluetoothReader(reader: Reader, activity: Activity? = null) {
val connectionConfig = ConnectionConfiguration.BluetoothConnectionConfiguration(reader.location?.id.orEmpty())
// val connectionConfig = ConnectionConfiguration.InternetConnectionConfiguration(true)

    Terminal.getInstance().connectBluetoothReader(reader, connectionConfig, activity?.get(), object : ReaderCallback {

// Terminal.getInstance().connectInternetReader(reader, connectionConfig, object : ReaderCallback {
override fun onSuccess(reader: Reader) {
mOnStripeTerminalListener.connectBluetoothReader(reader)
}
override fun onFailure(e: TerminalException) {
e.printStackTrace()
mOnStripeTerminalListener.connectBluetoothReader(reader, e.errorMessage)
}
})
}

#

ant it failed

grim harbor
#

what is the class of activity on line 193, I assume ReaderLocationsFragment but want to check

strong orchid
#

yes

#

it's Reader locationFragment

grim harbor
#

can you send those as non-rtf files, easier to open

strong orchid
grim harbor
#

how far does your code get into connectBluetoothReader() on your manager class? any specific part it crashes on?

strong orchid
#

the manager call connectBluetoothReader (Line 60) and it crashes on Reader(line 198)

grim harbor
opaque pagoda
#

@strong orchid unarchived, but not sure how much help I can be.

strong orchid
#

Hey @opaque pagoda

#

thanks!

#

I was checking the sample app

#

and in StripeTerminalApplication we have

#

public void onCreate() {
// Should happen before super.onCreate()
StrictMode.setThreadPolicy(
new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectAll()
.penaltyLog()
.build());

    StrictMode.setVmPolicy(
            new StrictMode.VmPolicy.Builder()
                    .detectLeakedSqlLiteObjects()
                    .detectLeakedClosableObjects()
                    .penaltyLog()
                    .penaltyDeath()
                    .build());

    super.onCreate();

    TerminalApplicationDelegate.onCreate(this);
}
#

but if i use this, i have this error

#

E/StripeTerminal: KoinApplication has not been started

#

Starting Koin i have this:

#

E/StripeTerminal: No definition found for class:'com.stripe.stripeterminal.external.callable.BluetoothReaderListener'. Check your definitions!

opaque pagoda
#

yeah to be clear, we looked at this with some colleagues and the only real sense we have here is _something _ about Koin and its dependency injection is causing a problem.

strong orchid
#

I think my problem is the Koin

opaque pagoda
#

but we don't use Koin or have any experience with it ourselves so it's hard to say

strong orchid
#

We could use another DI

#

I'm using Koin because of the log

#

Did you understand it?

opaque pagoda
#

understand what exactly?

strong orchid
#

About the Koin, I using the Koin DI.. because of the log on Android Studio

#

Thanks a lot for your help

opaque pagoda
#

I only found out Koin existed 5 minutes ago so I'm not too familiar with what advantages it has or how it adds logging capabilities ๐Ÿ˜…

strong orchid
#

ahahaha

opaque pagoda
#

as @grim harbor mentioned though maybe there's something special that needs to be done to pass the Activity instances to Koin like in that StackOverflow answer, not sure.

strong orchid
#

and i found out when Stripe terminal "recommend" it

#

I don't know, but i think my issue in how startKoin with the module

opaque pagoda
#

possibly!

strong orchid
#

waiting for @grim harbor

#

if you have some idea @opaque pagoda, let me know

#

sill trying to find some

opaque pagoda
#

I don't have any direct idea I'm afraid, no. Maybe try what's in that StackOverflow answer. I'm not sure anyone would have a better idea here beyond not using Koin, or trying to find out what is needed to make it work with our SDK, which you might have a better sense for, we don't use it ourselves and this is a new issue

strong orchid
#

Got it, but i used tha same Application class in Sample, and i got the error "startKoin"... so i don't know

opaque pagoda
#

I don't think you can just copy and paste our Application into an existing app using Koin, since doesn't Koin require you to call this startKoin function at the top level?

so really like you said: if you don't use startKoin (in our copy-pasted sample application) you get an error because you didn't start it; if you do start it, you get an error later about injecting that Bluetooth class.

So to me the options are to rip Koin out from your app entirely; or figure out what causes the injection error. I'd love to help you with the second option but nobody at Stripe is likely to have any great sense of how to proceed there (and it's a holiday for most of the company so there are not a lot of eyes to look at this right now unfortunately )

strong orchid
#

ok thanks a lot

#

I'll keep digging, if I didn't solve I'll come back here after the next week

#

๐Ÿ™‚

mystic ermine
#

Happy Holidays! ๐Ÿ™‚
The thread will be archived soon but if you have any follow ups later, you can ask the moderator (whoever is available) to re-open it.