#thiago-android-terminal
1 messages ยท Page 1 of 1 (latest)
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
thanks a lot!
implementation "com.stripe:stripeterminal:2.2.0"
when i use "internet" config
works like a charm
any idea?
still thinking, afaik that should still be the right import
try updating your dependency to v2.5.2 (latest) and sync gradle again and see: https://github.com/stripe/stripe-terminal-android/releases
Stripe Terminal Android SDK. Contribute to stripe/stripe-terminal-android development by creating an account on GitHub.
๐ @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?
one sec
val config = DiscoveryConfiguration(0, DiscoveryMethod.INTERNET, true) -> WORKS
val config = DiscoveryConfiguration(10, DiscoveryMethod.BLUETOOTH_SCAN, false) -> not work
thanks for that - let me dig a bit more
thanks @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
thanks!
๐ hey @strong orchid
do you wanna try force update/re-download the dependencies?
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
give me a sec to quickly repro this, one min
thanks @grim harbor
@strong orchid mind pasting the full import for BluetoothReaderListener that you're declaring in your Kotlin/Java file?
Feel free to continue here @strong orchid
@grim harbor do you mean about the #imports?
Yes, he's asking for the full import line for BluetoothReaderListener
Give me one min
It's weird, i don't have any imports for that
๐
Did i need any import?
like aren't you using that in the file? where you need to implement BluetoothReaderListener?
like how the example App imports it here
https://github.com/stripe/stripe-terminal-android/blob/37df6222c3a48ffc6c076056fd01e3cd2e187489/Example/javaapp/src/main/java/com/stripe/example/javaapp/MainActivity.java#L34
then implements that Listener interface on MainActivity
https://github.com/stripe/stripe-terminal-android/blob/37df6222c3a48ffc6c076056fd01e3cd2e187489/Example/javaapp/src/main/java/com/stripe/example/javaapp/MainActivity.java#L51
then implements any of the ReaderListener callbacks like
https://github.com/stripe/stripe-terminal-android/blob/37df6222c3a48ffc6c076056fd01e3cd2e187489/Example/javaapp/src/main/java/com/stripe/example/javaapp/MainActivity.java#L51
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
just added this one import com.stripe.stripeterminal.external.callable.BluetoothReaderListener
and nothing
any idea?
Catching up on this thread. One minute...
thanks @tribal anvil
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
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
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
what exact line does it crash on, is it sometime after it calls connectBluetoothReader() ? Or immediately on that line?
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
what is the class of activity on line 193, I assume ReaderLocationsFragment but want to check
can you send those as non-rtf files, easier to open
how far does your code get into connectBluetoothReader() on your manager class? any specific part it crashes on?
the manager call connectBluetoothReader (Line 60) and it crashes on Reader(line 198)
ah so some really helpful colleagues clued me in more, it looks like you're using koin for dep injection?
I'm not familiar with koin really but you might have to do something to get your activity's instance passed with koin, similar to this issue: https://stackoverflow.com/questions/61148093/koin-no-definition-found-for-class-but-already-declared
@strong orchid unarchived, but not sure how much help I can be.
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!
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.
I think my problem is the Koin
but we don't use Koin or have any experience with it ourselves so it's hard to say
We could use another DI
I'm using Koin because of the log
Did you understand it?
understand what exactly?
About the Koin, I using the Koin DI.. because of the log on Android Studio
Thanks a lot for your help
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 ๐
ahahaha
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.
and i found out when Stripe terminal "recommend" it
I don't know, but i think my issue in how startKoin with the module
possibly!
waiting for @grim harbor
if you have some idea @opaque pagoda, let me know
sill trying to find some
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
Got it, but i used tha same Application class in Sample, and i got the error "startKoin"... so i don't know
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 )
ok thanks a lot
I'll keep digging, if I didn't solve I'll come back here after the next week
๐
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.