'Unresolved Reference in Kotlin for an Interface defined in Base Class when addressed using Child Class

Hi I am trying to address an interface "CallbackTest" which is defined in my AudioBase.java using AudioChild.java which inherits the AudioBase.java. But it gives compilation error of Unresolved reference when trying to do so.

Here are my class definitions:

AudioBase.java

package com.testapp.kotlinexample.classes;

public class AudioBase {

    public interface CallbackTest {
        void onCall(int var1);
    }

}

Child Class AudioChild.java

package com.testapp.kotlinexample.classes;

import android.util.Log;

public class AudioChild extends AudioBase{

    private static final String TAG = "AudioChild";

    public void someOtherMethod() {
        Log.i(TAG, "in someOtherMethod()");
    }

}

MainActivity.kt

import android.content.Context
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.testapp.kotlinexample.classes.AudioChild


class MainActivity : AppCompatActivity() {

    private val TAG = "TestApp"
    private var mContext: Context? = null
    private val stateCallback =
        AudioChild.CallbackTest { // Compilation error on this line
            Log.i(TAG, "onCall:() called")
        }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        mContext = applicationContext
    }
}

When I use AudioChild.CallbackTest I get below compilation error:

Unresolved reference: CallbackTest

Can someone please help me understand why this error is coming?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source