ClassNotFoundException when talking to plugin

So I get a

java.lang.ClassNotFoundException

when trying to do this:

AndroidJavaClass jo = new AndroidJavaClass("com.example.plugintest");
		str = jo.Call<string>("returnLine");

I made a .jar from this:

package com.example.plugintest;

import com.unity3d.player.UnityPlayerActivity;

class Test extends UnityPlayerActivity{
	
	public String returnLine(){
		return "Hello World";
	}

}

and my project layout looks like this:

1163191--44528--$Capture.PNG

What am I doing wrong?

You are doing wrong several things.

First of all, you have to call: AndroidJNI.AttachCurrentThread(); once before you can call any JNI function.

Second, you create a reference to a Java-Class, not to an Java-Object-Instance and you use the packagename instead of the actual class name. When you have the Java-Class, you can call static function on that, no member function, because you don’t have an instance of that class. You also have to pass an empty parameter array:

AndroidJavaClass jc = new AndroidJavaClass("com.example.plugintest.Test");
str = jc.CallStatic<string>("returnLine", new object[0]);

For that to work, you also have to make your Java-Function static:

package com.example.plugintest;
 
import com.unity3d.player.UnityPlayerActivity;
     
class Test extends UnityPlayerActivity {
       
    public static String returnLine() {
        return "Hello World";
    }
}

I do not think you need to pass in an empty parameter array as there is no parameters in the java static method.

 str = jc.CallStatic<string>("returnLine");

Should be sufficient to call upon the static method.