#StackBounty: #java #android #android-studio #kotlin Unable to add library to Android Studio project

Bounty: 150

I’m trying to add this library to Android Studio locally using this tutorial on YouTube.

However, I get errors that I can’t post here because they’re too many (99+).

Can someone tell me step by step (in detail) how to succesfully add this library to my project and be able to edit it afterwards?

This is the main error I get when I try to import this library: Unable to determine constructor argument #1: missing parameter of type Factory, or no service of type Factory<LoggingManagerInternal>.

Get this bounty!!!

#StackBounty: #java #android #kotlin #swipe #android-tablayout Even with swiping disabled, tab continues to be changed with touch movem…

Bounty: 50

I am developing an application that uses the tablayout and contains 3 guides. The first is for general user information, the second guide is for additional information and the last guide is for the user to draw on the screen. is a third company that has problems, even with swiping disabled, when making drawing movements, the user ends up returning to the previous tab. So, I would like to know how to disable the movement of the swip on this screen, even with the movement between tabs it is already disabled with the sliding movement, without making it impossible for the drawing to be made.

One thing to note is that when you start drawing from the bottom up or up and down, you can draw without changing as guides, even if you are going somewhere later. However, if you start drawing

One thing I noticed, that when I start to draw from the bottom up or up and down, I can draw without changing the tabs, even if I go anywhere afterwards. However, if I start drawing anywhere, he understands that it is not the drawing but that I want to change tabs. How can I fix this?

class Main2Activity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    val sectionsPagerAdapter = SectionsPagerAdapter(this, supportFragmentManager)
    val viewPager: ViewPager = findViewById(R.id.viewPager)
    viewPager.adapter = sectionsPagerAdapter
    viewPager.setOnTouchListener { _, _ -> return@setOnTouchListener true }
    val tabs: TabLayout = findViewById(R.id.tabs)



<?xml version="1.0" encoding="utf-8"?>


        android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title" />

        android:background="?attr/colorPrimary" />



Image Fragment

class ImagesFragment : Fragment() {
override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
): View? {
    val view = inflater.inflate(R.layout.fragment_imagens, container, false)

Drawind starting from bottom/up or up/down

Drawind starting from left/right or right/left

Get this bounty!!!

#StackBounty: #kotlin #liquibase #corda #discordapp net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException: Could not…

Bounty: 50

I’m trying to develop a CorDapp using the example here. I’ve added two modules into my project, one for contracts and the other one for flows. I’ve added test cases for my contract and it works fine, but test cases for flow fail on setup stage. Here’s the code of my test class

 class SharedInformationFlowTests {
   private lateinit var network: MockNetwork
   private lateinit var a: StartedMockNode
   private val proposal = LedgerUpdateProposal.testProposal()

fun setup() {
    val params = MockNetworkParameters(cordappsForAllNodes = listOf(

    network = MockNetwork(params) //fails here
    a = network.createPartyNode()

fun tearDown() {

And here are the error messages I get:

[WARN] 13:42:52,620 [main] spi.SqlExceptionHelper. - SQL Error: 0, SQLState: null {changeSet=migration/vault-schema.changelog-v9.xml::update-vault-states::R3.Corda, databaseChangeLog=master.changelog.json}
[ERROR] 13:42:52,620 [main] spi.SqlExceptionHelper. - Connection is closed {changeSet=migration/vault-schema.changelog-v9.xml::update-vault-states::R3.Corda, databaseChangeLog=master.changelog.json}

net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException: Could not create the 
DataSource: Migration failed for change set migration/vault-schema.changelog-v9.xml::update-vault-states::R3.Corda:
 Reason: net.corda.nodeapi.internal.persistence.HibernateConfigException: Could not create Hibernate configuration: Unable to open JDBC Connection for DDL execution

I think there’s something wrong with the liquibase. I’ve tried adding changelog file to my resources/migration directory as advised here, but it doesn’t seem to have any effect. Please help.

UPDATE Added schema

 * The family of com.sentinel.schemas for SharingInformationState.
object SharingInformationSchema

 * An SharingInformationState schema.
object SharingInformationSchemaV1 : MappedSchema(
    schemaFamily = SharingInformationSchema.javaClass,
    version = 1,
    mappedTypes = listOf(PersistentSharingInformation::class.java)) {
override val migrationResource: String? = "sharing-information-schema-v1.changelog-master.xml"

@Table(name = "persistent_sharing_information")
class PersistentSharingInformation(
        @Column(name = "owner_id")
        var dataOwnerId: Long,

        @Column(name = "buyer_id")
        var dataBuyerId: Long,

        @Column(name = "start_date")
        val startDate: String,

        @Column(name = "end_date")
        val endDate: String,

        @Column(name = "shared_fields")
        val sharedFieldsIds: String,

        @Column(name = "agreement_status")
        val agreementStatus: String,

        @Column(name = "contract_type")
        val contractType: String,

        @Column(name = "linear_id")
        var linearId: UUID
) : PersistentState() {

    // Default constructor required by hibernate.
    constructor() : this(0L,  0L,
            "", "", "[]", "", "", UUID.randomUUID())


Get this bounty!!!

#StackBounty: #android #kotlin #dagger-2 Dagger2 Android DI – lateinit property has not been initialized

Bounty: 50

I am working on project with Dagger2 for DI. I am injecting presenter in MVP architecture.
For some reason when I build app it crashes with error:
“lateinit property presenter has not been initialized”. I know it means that injection is not made but I don’t understand why. Here is my code:


class FlowerApp : Application() {

override fun onCreate() {

private fun initAppComponent() {
    appComponent = DaggerAppComponent

companion object {
    lateinit var appComponent: AppComponent


class HomeModule(var homeFragment: HomeContract.View) {
    fun providePresenter(homeInteractor: HomeInteractor): HomePresenter {
        return HomePresenter(homeFragment, homeInteractor)

    fun provideInteractor(): HomeInteractor {
        return HomeInteractor()


    modules = [

interface AppComponent {
    fun inject(application: FlowerApp)
    fun inject(homeFragment: HomeContract.View)


class HomeFragment : Fragment(), HomeContract.View {
    lateinit var presenter: HomePresenter
    private lateinit var flowerAdapter: FlowerAdapter
    private var startingPage = 1
    private var recyclerStartPos = 0

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.fragment_home, container, false)

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

    override fun onCreate(savedInstanceState: Bundle?) {

If any other info about code needed just ask…

Get this bounty!!!

#StackBounty: #java #python #android #opencv #kotlin How to convert a targeting code in python to kotlin?

Bounty: 50

I am developing an image segmentation application that will use watershed. For that, I found a code that I will need to use in python. However, I am having difficulty converting to kotlin, since the lib Mat () does not have the function of zero_likes only the function zero. Estou utilizando o opencv 3.31

Code python:

import cv2
import numpy as np
import matplotlib.pyplot as plt

# Load the image
img = cv2.imread("/path/to/image.png", 3)

# Create a blank image of zeros (same dimension as img)
# It should be grayscale (1 color channel)
marker = np.zeros_like(img[:,:,0]).astype(np.int32)

# This step is manual. The goal is to find the points
# which create the result we want. I suggest using a
# tool to get the pixel coordinates.

# Dictate the background and set the markers to 1
marker[204][95] = 1
marker[240][137] = 1
marker[245][444] = 1
marker[260][427] = 1
marker[257][378] = 1
marker[217][466] = 1

# Dictate the area of interest
# I used different values for each part of the car (for visibility)
marker[235][370] = 255    # car body
marker[135][294] = 64     # rooftop
marker[190][454] = 64     # rear light
marker[167][458] = 64     # rear wing
marker[205][103] = 128    # front bumper

# rear bumper
marker[225][456] = 128
marker[224][461] = 128
marker[216][461] = 128

# front wheel
marker[225][189] = 192
marker[240][147] = 192

# rear wheel
marker[258][409] = 192
marker[257][391] = 192
marker[254][421] = 192

# Now we have set the markers, we use the watershed
# algorithm to generate a marked image
marked = cv2.watershed(img, marker)

# Plot this one. If it does what we want, proceed;
# otherwise edit your markers and repeat
plt.imshow(marked, cmap='gray')

# Make the background black, and what we want to keep white
marked[marked == 1] = 0
marked[marked > 1] = 255

# Use a kernel to dilate the image, to not lose any detail on the outline
# I used a kernel of 3x3 pixels
kernel = np.ones((3,3),np.uint8)
dilation = cv2.dilate(marked.astype(np.float32), kernel, iterations = 1)

# Plot again to check whether the dilation is according to our needs
# If not, repeat by using a smaller/bigger kernel, or more/less iterations
plt.imshow(dilation, cmap='gray')

# Now apply the mask we created on the initial image
final_img = cv2.bitwise_and(img, img, mask=dilation.astype(np.uint8))

# cv2.imread reads the image as BGR, but matplotlib uses RGB
# BGR to RGB so we can plot the image with accurate colors
b, g, r = cv2.split(final_img)
final_img = cv2.merge([r, g, b])

# Plot the final result

code kotlin:

private fun watershed() {
    // Load the image
    val srcOriginal = Imgcodecs.imread(currentPhotoPath)

    // Create a blank image of zeros (same dimension as img)
    // It should be grayscale (1 color channel)
    val markers = Mat.zeros(srcOriginal.rows(), srcOriginal.cols(), CvType.CV_64FC1)

    // This step is manual. The goal is to find the points
    // which create the result we want. I suggest using a
    // tool to get the pixel coordinates.

    // Dictate the area of interest
    for (i in my_canvas?.pointsFrontToDrawX?.indices!!) {
        markers[my_canvas.pointsToDrawX[i], my_canvas.pointsToDrawY[i]] = 1


    // Dictate the background and set the markers to 1
    for (i in my_canvas?.pointsBackToDrawX?.indices!!) {
        markers[my_canvas.pointsToDrawX[i], my_canvas.pointsToDrawY[i]] = 255

    //Create Bitmap
    result_Bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565)
    Utils.matToBitmap(markers, result_Bitmap)

In pointsToDrawX and pointsToDrawY I’m saving all the x, y coordinates of the user’s touch event on the screen. It is from these coordinates that I will pass to the watershed algorithm to perform the segmentation and remove the background from the image. Can someone help me convert this code?

Get this bounty!!!

#StackBounty: #java #android #opencv #kotlin #image-processing how to add coordinates in the segmentation of the watershed?

Bounty: 50

I am developing an application that removes the background of images according to the coordinates drawn on the screen by the user. The user draws a rectangle around the image of interest. With this I use watershed to segment the image and remove the background from the image. However, I’m having trouble inserting the coordinates in the algorithm so that the entire background is removed. In the image below I select only 4 coins, after segmentation, I want only those 4 coins to remain in the image and the others disappear. However, this is not what is happening. Can someone help me do this removal segment based on the region passed by the user?

enter image description here


    typealias Coordinates = Pair<Point, Point>    
    private fun extractForegroundFromBackground(coordinates: Coordinates){
    // TODO: Provide complex object that has both path and extension

    val width: Int
    val height: Int
    width = bitmap.getWidth()
    height = bitmap.getHeight()
    val rect = Rect(coordinates.first, coordinates.second)
    val rgba = Mat()
    val gray_mat = Mat()
    val threeChannel = Mat()

    Utils.bitmapToMat(bitmap, gray_mat)

    Imgproc.cvtColor(gray_mat, rgba, Imgproc.COLOR_RGBA2RGB)

    Imgproc.cvtColor(rgba, threeChannel, Imgproc.COLOR_RGB2GRAY)
    Imgproc.threshold(threeChannel, threeChannel, 100.0, 255.0, Imgproc.THRESH_OTSU)

    val fg = Mat(rgba.size(), CvType.CV_8U)
    Imgproc.erode(threeChannel, fg, Mat(), Point(-1.0, -1.0), 2)

    val bg = Mat(rgba.size(), CvType.CV_8U)
    Imgproc.dilate(threeChannel, bg, Mat(), Point(-1.0, -1.0), 3)
    Imgproc.threshold(bg, bg, 1.0, 128.0, Imgproc.THRESH_BINARY_INV)

    val markers = Mat(rgba.size(), CvType.CV_8U, Scalar(0.0))
    Core.add(fg, bg, markers)

    // Start the WaterShed Segmentation :
    val marker_tempo = Mat()
    markers.convertTo(marker_tempo, CvType.CV_32S)

    Imgproc.watershed(rgba, marker_tempo)
    marker_tempo.convertTo(markers, CvType.CV_8U)

    result_Bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565)

    Imgproc.applyColorMap(markers, markers, COLORMAP_BONE)
    Utils.matToBitmap(markers, result_Bitmap)


    return currentPhotoPath


enter image description here

expected output:

enter image description here

Get this bounty!!!

#StackBounty: #android #android-layout #kotlin #android-imageview #android-view Change source image for all backgrounds when imageview …

Bounty: 50

I would like to change the background of all the layers when I click an imageview, for example this imageview has the preview of yellow colour but when I click it I would like to change the background to
an image with the name of fondoamarillo.jpg , my layer name is colores and my kt is Colores


This is the .kt

fun onCambio(view: View){

    imageView41.setOnClickListener {


    //setBackgroundResource change the background of the imageView


Get this bounty!!!

#StackBounty: #android #kotlin #android-jetpack #android-navigation #android-jetpack-navigation Navigation Component: jump to dynamic r…

Bounty: 50

When using Jetpack Navigation, we can use popUpTo and popInclusive to clear the stack. But how do I clear the stack when I don’t know what destination to popUpto?


Say I have 3 main destinations that should have a clear stack when we arrive at them. And each main destination has its own flow of screens (which can be accessed directly with a deeplink).

Assuming the navigation flows downwards here:

Start app:
 - Main Dest 1 (nav to dest 2)
     - Dest 2 (nav to dest 3)
         - Dest 3 (nav to main dest 2)
 - (with clear stack)
   Main Dest 2 (nav to dest 4)
     - Dest 4 (nav to main dest 3)
 - (with clear stack)
   Main Dest 3
 - Back button should close the app here

Since the navigation is very dynamic, I cannot guarantee the root destination. Even though I could, for example, pop up to “Main Dest 2”, I cannot know that it’s on the stack since I might have gone directly to “dest 4” from a URL.

I there a way of knowing which destination is the lowest so I can pop up to it and clear the stack?

Get this bounty!!!