Add proximity events to an Android app

I am new on JAVA and beacons programing. Kindly assist me to clear the following errors:

error: cannot find symbol class Function1||
error: cannot find symbol class Unit||
error: cannot find symbol class Unit||
error: method does not override or implement a method from a supertype||
error: cannot find symbol variable Log||

My code is as follows:

package com.example.indoornav;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.estimote.proximity_sdk.api.EstimoteCloudCredentials;
import com.estimote.proximity_sdk.api.ProximityObserverBuilder;
import com.estimote.proximity_sdk.api.ProximityObserver;

public class MainActivity extends AppCompatActivity {
    private ProximityObserver proximityObserver;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        EstimoteCloudCredentials cloudCredentials =
            new EstimoteCloudCredentials("APP ID", "APP TOKEN");

        this.proximityObserver =
                new ProximityObserverBuilder(getApplicationContext(), cloudCredentials)
                        .onError(new Function1<Throwable, Unit>() {

                            @Override

                            public Unit invoke(Throwable throwable) {
                                Log.e("app", "proximity observer error: " + throwable);
                                return null;
                            }
                        })
                        .withBalancedPowerMode()
                        .build();



        }
}

It seems you’re just missing some import statements. In Android Studio, if you however over the red symbol that’s missing the import (here, you should have your Function1, Unit, and Log show up red), you should get a little menu that will allow you to add an appropriate import.

I’ve cleared all the errors. However i cannot get the app past “Hello World!”. It does not detect the beacons.

Even when I want to connect through the Estimote App, I need to shake and tap the beacon a number of times before the bluetooth connection is successful.

After connecting the Bluetooth, it takes a very long time to connect to the Estimote cloud. Someone please advise me. This is so frustrating.

Kindly see my code below (I’ve deleted some ID, Token Credentials for security):

package com.example.indoornav;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.estimote.mustard.rx_goodness.rx_requirements_wizard.Requirement;
import com.estimote.mustard.rx_goodness.rx_requirements_wizard.RequirementsWizardFactory;
import com.estimote.proximity_sdk.api.EstimoteCloudCredentials;
import com.estimote.proximity_sdk.api.ProximityObserverBuilder;
import com.estimote.proximity_sdk.api.ProximityObserver;
import com.estimote.proximity_sdk.api.ProximityZoneBuilder;
import com.estimote.proximity_sdk.api.ProximityZone;
import com.estimote.proximity_sdk.api.ProximityZoneContext;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;

public class MainActivity extends AppCompatActivity {
private ProximityObserver proximityObserver;
private ProximityObserver ProximityZone;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    EstimoteCloudCredentials cloudCredentials =
        new EstimoteCloudCredentials("vuyani-sidinile-s-inda-exx", "ab52d734f0e7884c2fc90e10e52f5");

    this.proximityObserver =
            new ProximityObserverBuilder(getApplicationContext(), cloudCredentials)
                    .onError(new Function1<Throwable, Unit>() {

                        @Override

                        public Unit invoke(Throwable throwable) {
                            Log.e("app", "proximity observer error: " + throwable);
                            return null;
                        }
                    })
                    .withBalancedPowerMode()
                    .build();

    final ProximityZone zone = new ProximityZoneBuilder()
            .forTag("Toilet")
            .inCustomRange (3.0)
            //.inNearRange()
            .onEnter(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    String deskOwner = context.getAttachments().get("Location");
                    Log.d("Toilet", "Welcome to " + deskOwner + "'s desk");
                    return null;
                }
            })
            .onExit(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    Log.d("Toilet", "Bye bye, come again!");
                    return null;
                }
            })
           // .build();

        .onContextChange(new Function1<Set<? extends ProximityZoneContext>, Unit>() {
        @Override
        public Unit invoke(Set<? extends ProximityZoneContext> contexts) {
            List<String> deskOwners = new ArrayList<>();
            for (ProximityZoneContext context : contexts) {
                deskOwners.add(context.getAttachments().get("Location"));
            }
            Log.d("app", "In range of desks: " + deskOwners);
            return null;
        }
    }   )
            .build();

   /* final ProximityZone zone1 = new ProximityZoneBuilder()
            .forTag("Room")
            .inNearRange()
            .onEnter(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    String deskOwner = context.getAttachments().get("Location");
                    Log.d("app", "Welcome to " + deskOwner + "'s desk");
                    return null;
                }
            })
            .onExit(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    Log.d("app", "Bye bye, come again!");
                    return null;
                }
            })
            // .build();

            .onContextChange(new Function1<Set<? extends ProximityZoneContext>, Unit>() {
                @Override
                public Unit invoke(Set<? extends ProximityZoneContext> contexts) {
                    List<String> deskOwners = new ArrayList<>();
                    for (ProximityZoneContext context : contexts) {
                        deskOwners.add(context.getAttachments().get("Location"));
                    }
                    Log.d("app", "In range of desks: " + deskOwners);
                    return null;
                }
            }   )
            .build();

    final ProximityZone zone2 = new ProximityZoneBuilder()
            .forTag("Kitchen")
            .inNearRange()
            .onEnter(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    String deskOwner = context.getAttachments().get("Location");
                    Log.d("app", "Welcome to " + deskOwner + "'s desk");
                    return null;
                }
            })
            .onExit(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    Log.d("app", "Bye bye, come again!");
                    return null;
                }
            })
            // .build();

            .onContextChange(new Function1<Set<? extends ProximityZoneContext>, Unit>() {
                @Override
                public Unit invoke(Set<? extends ProximityZoneContext> contexts) {
                    List<String> deskOwners = new ArrayList<>();
                    for (ProximityZoneContext context : contexts) {
                        deskOwners.add(context.getAttachments().get("Location"));
                    }
                    Log.d("app", "In range of desks: " + deskOwners);
                    return null;
                }
            }   )
            .build();

    final ProximityZone zone3 = new ProximityZoneBuilder()
            .forTag("Dinning")
            .inNearRange()
            .onEnter(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    String deskOwner = context.getAttachments().get("Location");
                    Log.d("app", "Welcome to " + deskOwner + "'s desk");
                    return null;
                }
            })
            .onExit(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    Log.d("app", "Bye bye, come again!");
                    return null;
                }
            })
            // .build();

            .onContextChange(new Function1<Set<? extends ProximityZoneContext>, Unit>() {
                @Override
                public Unit invoke(Set<? extends ProximityZoneContext> contexts) {
                    List<String> deskOwners = new ArrayList<>();
                    for (ProximityZoneContext context : contexts) {
                        deskOwners.add(context.getAttachments().get("Location"));
                    }
                    Log.d("app", "In range of desks: " + deskOwners);
                    return null;
                }
            }   )
            .build();*/
    RequirementsWizardFactory
            .createEstimoteRequirementsWizard()
            .fulfillRequirements(this,
                    // onRequirementsFulfilled
                    new Function0<Unit>() {
                        @Override public Unit invoke() {
                            Log.d("app", "requirements fulfilled");
                            proximityObserver.startObserving(zone);
                            return null;
                        }
                    },
                    // onRequirementsMissing
                    new Function1<List<? extends Requirement>, Unit>() {
                        @Override public Unit invoke(List<? extends Requirement> requirements) {
                            Log.e("app", "requirements missing: " + requirements);
                            return null;
                        }
                    },
                    // onError
                    new Function1<Throwable, Unit>() {
                        @Override public Unit invoke(Throwable throwable) {
                            Log.e("app", "requirements error: " + throwable);
                            return null;
                        }
                    });

    }

}