Estimote / Android-Fleet-Management-SDK

Estimote Fleet Management SDK for Android
https://developer.estimote.com
MIT License
835 stars 451 forks source link

Unable to compile, error: package com.estimote.sdk does not exist #227

Closed thomas-alrek closed 7 years ago

thomas-alrek commented 7 years ago

Hello.

I am trying to build a Cordova based project, and am unable to compile.

I have added

dependencies {
   compile 'com.estimote:sdk:1.0.3:release@aar'
}

In a custom gradle file. And I have verified that the dependency has been downloaded

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Subproject Path: CordovaLib
Incremental java compilation is an incubating feature.
Download https://repo1.maven.org/maven2/com/estimote/sdk/1.0.3/sdk-1.0.3-release.aar
:preBuild UP-TO-DATE

This is what happens when I try to build the project:

BUILD FAILED

Total time: 9.928 secs
Error: /Users/thomasalrek/dev/test/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/thomasalrek/Dev/test/platforms/android/src/no/apility/cordova/EstimoteWrapper.java:7: error: package com.estimote.sdk does not exist
import com.estimote.sdk.*;
^
/Users/thomasalrek/Dev/test/platforms/android/src/no/apility/cordova/EstimoteWrapper.java:31: error: cannot find symbol
    if (SystemRequirementsChecker.checkWithDefaultDialogs(this)) {
        ^
  symbol:   variable SystemRequirementsChecker
  location: class EstimoteWrapper
/Users/thomasalrek/Dev/test/platforms/android/src/org/apache/cordova/file/AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':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.

Any idea what might be the problem?

will-orozco commented 7 years ago

You need to change/modify imports.

Example: import com.estimote.coresdk.common.config.EstimoteSDK; import com.estimote.coresdk.observation.region.Region; import com.estimote.coresdk.observation.region.RegionUtils; import com.estimote.coresdk.observation.region.beacon.BeaconRegion; import com.estimote.coresdk.observation.utils.Proximity; import com.estimote.coresdk.recognition.packets.Beacon; import com.estimote.coresdk.service.BeaconManager;

thomas-alrek commented 7 years ago

Thanks for the tips! I must have been following an old guide.

However, I am still not able to build.

BUILD FAILED

Total time: 12.327 secs
Error: /Users/thomasalrek/dev/test/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/thomasalrek/Dev/test/platforms/android/src/no/apility/cordova/EstimoteWrapper.java:7: error: package com.estimote.coresdk.common does not exist
import com.estimote.coresdk.common.requirements;
                                  ^
/Users/thomasalrek/Dev/test/platforms/android/src/no/apility/cordova/EstimoteWrapper.java:31: error: cannot find symbol
                if (SystemRequirementsChecker.checkWithDefaultDialogs(this)) {
                    ^
  symbol:   variable SystemRequirementsChecker
  location: class EstimoteWrapper
2 errors

FAILURE: Build failed with an exception.

I double checked the class namespace, and it should be correct now, according to the documentation.

https://estimote.github.io/Android-SDK/JavaDocs/com/estimote/coresdk/common/requirements/SystemRequirementsChecker.html#checkWithDefaultDialogs-android.app.Activity-

I can't really spot any thing obvious that could cause this.

package no.apility.cordova;

import org.json.JSONArray;
import org.apache.cordova.*;
import org.json.JSONException;
import com.estimote.coresdk.common.requirements;

public class EstimoteWrapper extends CordovaPlugin
{
    private static final String tag = "EstimoteWrapper";

     /**
     * Plugin initializer.
     */
    @Override
    public void initialize(CordovaInterface cordova, CordovaWebView webView) {
        super.initialize(cordova, webView);
        Log.i(tag, "initialize");
    }

    public boolean requestAlwaysAuthorization(final CallbackContext callbackContext) {
        Log.i(tag, "requestAlwaysAuthorization");
        if (SystemRequirementsChecker.checkWithDefaultDialogs(this)) {
            callbackContext.success(1);
            return true;
        }
        callbackContext.error(0);
        return false;
    }

    public boolean requestWhenInUseAuthorization(final CallbackContext callbackContext) {
        Log.i(tag, "requestWhenInUseAuthorization");
        if (requestAlwaysAuthorization(callbackContext)) {
            callbackContext.success(1);
            return true;
        }
        callbackContext.error(0);
        return false;
    }

    /**
     * Plugin reset.
     * Called when the WebView does a top-level navigation or refreshes.
     */
    @Override
    public void onReset() {
        super.onReset();
        Log.i(tag, "onReset");
    }

    /**
     * The final call you receive before your activity is destroyed.
     */
    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(tag, "onDestroy");
    }

    /**
     * Entry point for JavaScript calls.
     */
    @Override
    public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
        Log.i(tag, "execute " + action);

        if (action == null) {
            return false;
        }

        if ("requestAlwaysAuthorization".equals(action)) {
            return requestAlwaysAuthorization(callbackContext);
        }

        if ("requestWhenInUseAuthorization".equals(action)) {
            return requestWhenInUseAuthorization(callbackContext);
        }

        return false;
    }
}
xcastoreo commented 7 years ago

Hi @thomas-alrek,

are you sure you're importing well? I would write this:

import com.estimote.coresdk.common.requirements.SystemRequirementsChecker;

to import the SystemRequirementsChecker class.

thomas-alrek commented 7 years ago

Yeah @xcastoreo that worked! Thanks