Invoke: no method named `DoSomething' in class java.lang.Boolean

I made an extension, compiled it, and running a simple function gives me this error:
invoke: no method named \DoSomething' in class java.lang.Boolean`
Someone help me out pls

package me.derek.utils;


import android.app.Activity;

import com.google.appinventor.components.annotations.DesignerComponent;

import com.google.appinventor.components.annotations.SimpleFunction;

import com.google.appinventor.components.annotations.SimpleObject;

import com.google.appinventor.components.annotations.UsesPermissions;

import com.google.appinventor.components.common.ComponentCategory;

import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;

import com.google.appinventor.components.runtime.ComponentContainer;


@DesignerComponent(version = 0,

description="A utiity thingy, made by derek",

category = ComponentCategory.EXTENSION,

nonVisible = true,

androidMinSdk = 21)

@SimpleObject(external = true)

class Utils extends AndroidNonvisibleComponent{


private final Activity activity;


public Utils(ComponentContainer container) {

super(container.$form());

activity = container.$context();

}


@SimpleFunction(description = "Does something, idk")

public void DoSomething() {

}


}

Are you using an iOS device (iPhone/iPad/macOS)? Extensions cannot run on iOS as of October 2023. Please use an Android emulator or phone instead.

You should append the modifier: public before classs Utils because otherwise it will be declared as package protected and accessing it from outside the classes of your extension will be impossible so Appinventor won't be able to invoke the methods of your extension.
Example of the correct declaration:
public class Utils extends AndroidNonvisibleComponent{

3 Likes

Thanks!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.