0

I'm integrating hypersdkflutter into a flutter app. As part of the setup, I have to change FlutterActivity to FlutterFragmentActivity in my MainActivity.kt file. Everything used to work before this change but after making this change, I'm getting following error

Property delegate must have a 'getValue(MainActivity, KProperty<*>)' method. None of the following functions is suitable: 
public inline operator fun <T> Lazy<String>.getValue(thisRef: Any?, property: KProperty<*>): String defined in kotlin 

Full console log here - https://pastebin.com/1gzWC90F

This is what my MainActivity.kt looks like

package com.package_name

import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.media.AudioManager
import android.media.MediaScannerConnection
import android.net.Uri
import android.util.Log
import androidx.core.content.FileProvider
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import java.io.File
import java.io.IOException


class MainActivity : FlutterFragmentActivity() {
    private val AUDIO_RECORDER_CHANNEL = "com.package_name/audio_recorder"
    private val SHARE_CHANNEL = "com.package_name/share"

    private val providerAuthority: String by lazy {
        context.packageName + ".package_name.share_provider"
    }

     override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        flutterEngine.plugins.add(ReceiveSharing())
        
        ...
    }

    ...
}

I found a similar thread on SO but I'm unable to understand the problem.

I'm not fluent with Kotlin so any help or references to docs would be very helpful. Thanks in adavnce.

Ashutosh Singh
  • 1,107
  • 17
  • 28

1 Answers1

0

Figured out the solution. The problem was not with the missing getters or property delegate but it was because context and activity were not defined for FlutterFragmentActivity. Had to use replace them with applicationContext and this respectively.

Source - getContext() and getActivity() with FragmentActivity

Ashutosh Singh
  • 1,107
  • 17
  • 28