I am working on an Android project in Java using the Estimote UWB SDK. I get a build error saying, “Duplicate class kotlin.collections.jdk8 found in modules kotlin-stdlib-1.8.0 and kotlin-stdlib-jdk8-1.6.0.” I don’t believe any of my Java code has kotlin dependencies so I am wondering if the conflict is in the Estimote UWB SDK. Has anyone else experienced this?
I am using Ionic/Vue with capacitor plugins, for android, written in Java…
I do not see that error in my plugin for Estimote beacons
I have started over a couple times trying to convert the 3 page Android UWB instructions from Kotlin to Java. I no longer get the “Duplicate class” error but I have not been able to get uwbManager.init to resolve in my MainActivity. Does anybody know what dumb thing I am doing, or not doing?
Below is my interface code and Main Activity Code:
package com.example.estimoteuwbjavatest;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import androidx.activity.result.ActivityResultCaller;
import com.estimote.uwb.api.ranging.EstimoteUWBRangingResult;
import com.estimote.uwb.api.requirements.DeniedRequirement;
import com.estimote.uwb.api.scanning.EstimoteDevice;
import java.util.List;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.jvm.functions.Function1;
import kotlinx.coroutines.flow.Flow;
public interface EstimoteUWBManager {
void init(
Context context,
ActivityResultCaller activityResultCaller,
Function1<? super Throwable, Unit> onError,
Function1<? super List, Unit> onDenied
);
void startDeviceScanning(Context context);
void stopDeviceScanning();
Flow<List<EstimoteDevice>> getUwbDevices();
void connect(BluetoothDevice bluetoothDevice, Context context, Continuation<? super Unit> continuation);
void disconnectDevice();
Flow<EstimoteUWBRangingResult> getRangingResult();
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultCaller;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.ActivityResultRegistry;
import androidx.activity.result.contract.ActivityResultContract;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityOptionsCompat;
import android.content.Intent;
import android.os.Bundle;
import com.estimote.uwb.api.EstimoteUWBFactory;
import com.estimote.uwb.api.EstimoteUWBManager;
import com.estimote.uwb.api.requirements.DeniedRequirement;
import java.util.List;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlinx.coroutines.Job;
public class MainActivity extends AppCompatActivity {
private EstimoteUWBManager uwbManager;
private Job job;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uwbManager = EstimoteUWBFactory.Companion.create();
uwbManager.init(this, new MyActivityResultCaller(), new MyOnErrorListener(), new MyOnDeniedListener());
setContentView(R.layout.activity_main);
}
private class MyActivityResultCaller extends ActivityResultLauncher<Intent> implements ActivityResultCaller {
@Override
public void launch(Intent input, @Nullable ActivityOptionsCompat options) {
}
@Override
public void unregister() {
// Implement the unregister method
}
@NonNull
@Override
public ActivityResultContract<Intent, ?> getContract() {
return null;
}
@NonNull
@Override
public <I, O> ActivityResultLauncher<I> registerForActivityResult(@NonNull ActivityResultContract<I, O> contract, @NonNull ActivityResultCallback<O> callback) {
return null;
}
@NonNull
@Override
public <I, O> ActivityResultLauncher<I> registerForActivityResult(@NonNull ActivityResultContract<I, O> contract, @NonNull ActivityResultRegistry registry, @NonNull ActivityResultCallback<O> callback) {
return null;
}
}
private class MyOnErrorListener implements Function1<Throwable, Unit> {
@Override
public Unit invoke(Throwable throwable) {
// Handle error
return Unit.INSTANCE;
}
}
private class MyOnDeniedListener implements Function1<List<DeniedRequirement>, Unit> {
@Override
public Unit invoke(List<DeniedRequirement> deniedRequirements) {
// Handle denied requirements
return Unit.INSTANCE;
}
}
}