Playing with UNO/JAVA

Hi there, sorry for the trouble, but i will need some help undersanding how connect Java and UNO.

well i have some random code in java.

/**
 * toast
 */
import com.fuse.Activity;
import android.widget.Toast;
import android.content.Context;
public class Alert {
    public void message(String Text){
       
        
    }
}

and some random code in UNO

using Uno.Threading;
using Uno;
using Uno.Collections;
using Uno.UX;
using Uno.Compiler.ExportTargetInterop;
using Android;
using Uno.Permissions;
using Fuse;
using Fuse.Scripting;
using Fuse.Triggers.Actions;
using Uno.Compiler.ExportTargetInterop;


[extern(Android) ForeignInclude(
    Language.Java,
    "android.content.Context",
    "android.speech.tts.TextToSpeech",
    "android.speech.tts.TextToSpeech.OnInitListener",
    "java.util.Locale")]

[UXGlobalModule]
public class Basics : NativeModule{
	static readonly Basics _instance;
    public Basics(){

    	if (_instance != null) return;
    	_instance = this;
    	Resource.SetGlobalKey(_instance, "Basics");
        AddMember(new NativeFunction("voiceReader",(NativeCallback)voiceReader));
    }
    public static extern (!Android) object voiceReader(Context c,object[] text){
        debug_log "Imagina que mandas mensaje: "+text[0];
        text=null;
        return text;
    }
    public static extern (Android) object voiceReader(Context c,object[] text){
        reader();
        return null;
    }
    [Foreign(Language.Java)]
    public extern(Android) static void reader()
	@{
		Alert toast=new Alert();
                toast.message("hola mundo");
	@} 
}

the problem is that i cant link these together, what is missing?

$ fuse build -t=Android -c=Preview
Uno 1.3.2 (build 5946) Windows 10 x64 f04d7e8


Configuring
 (1.0 s)
Compiling syntax tree
 (2.7 s)
Generating code and data
 (5.2 s)
Building Android app


C:\Users\Alberto\Documents\Fuse\Critica\build\Android\Preview\app\src\main\java\com\apps\critica\critica.java:35: error: cla
ss Critica is public, should be declared in a file named Critica.java
public class Critica extends android.support.v7.app.AppCompatActivity implements ActivityCompat.OnRequestPermissionsResultCa
llback
       ^

C:\Users\Alberto\Documents\Fuse\Critica\build\Android\Preview\app\src\main\java\com\foreign\Basics.java:40: error: cannot fi
nd symbol
        Alert toast=new Alert();
        ^
  symbol:   class Alert

  location: class Basics

C:\Users\Alberto\Documents\Fuse\Critica\build\Android\Preview\app\src\main\java\com\foreign\Basics.java:40: error: cannot fi
nd symbol

        Alert toast=new Alert();

                        ^

  symbol:   class Alert

  location: class Basics
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2340Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase920Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement920Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps920Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasks920Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugJavaWithJavac FAILED

BUILD FAILED

Total time: 14.369 secs

(15.8 s)

Build completed in 24.68 seconds
    1 error


(unknown): E0200: Android build failed

 

Well the Alert you’re trying to use in the .uno file lives in a separate .java file. As far as I can tell, you have not included that .java file in the .uno file, hence it throws that error. Perhaps adding the .java file to the ForeignInclude would solve the issue at hand.

Please spend some time in our Foreign code docs, that should get you going.