Search code examples
androideclipseandroid-studiogoogle-glassgoogle-gdk

Project runs from eclipse but when exported to gradle async throws error


I'm trying to get the BarcodeEye working in my own project. When I import the project in eclipse and try to run it it's working perfectly.

I then tried the following 3 ways of getting it in android studio.

  1. First I copied all the files that are required from the existing project into my own project. After setting all te correct imports and package names I got 4 errors when I tried to build it(Will post errors below)
  2. I opened the eclipse project directly in android studios and tried to build it. I got 4 errors(See below)
  3. I exported the eclipse project to gradle and then opened it in android studio. Again I got 4 errors.

Does anyone have a clue what is going wrong here?

Errors

    C:\Users\xx\xx\BarcodeEye\src\com\google\zxing\client\android\camera\AutoFocusManager.java:59: error: method executeOnExecutor in class AsyncTask<Params,Progress,Result> cannot be applied to given types;
      outstandingTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                     ^
  required: Executor,CAP#1[]
  found: Executor
  reason: formal varargs element type CAP#1 is not accessible from class AutoFocusManager
  where Params,Progress,Result are type-variables:
    Params extends Object declared in class AsyncTask
    Progress extends Object declared in class AsyncTask
    Result extends Object declared in class AsyncTask
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object from capture of ?
C:\Users\xx\xx\BarcodeEye\src\com\github\barcodeeye\migrated\InactivityTimer.java:50: error: method executeOnExecutor in class AsyncTask<Params,Progress,Result> cannot be applied to given types;
        inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                      ^
  required: Executor,CAP#1[]
  found: Executor
  reason: formal varargs element type CAP#1 is not accessible from class InactivityTimer
  where Params,Progress,Result are type-variables:
    Params extends Object declared in class AsyncTask
    Progress extends Object declared in class AsyncTask
    Result extends Object declared in class AsyncTask
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object from capture of ?
C:\Users\xx\xx\BarcodeEye\src\com\google\zxing\client\android\share\AppPickerActivity.java:35: error: method executeOnExecutor in class AsyncTask<Params,Progress,Result> cannot be applied to given types;
    backgroundTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                  ^
  required: Executor,CAP#1[]
  found: Executor
  reason: formal varargs element type CAP#1 is not accessible from class AppPickerActivity
  where Params,Progress,Result are type-variables:
    Params extends Object declared in class AsyncTask
    Progress extends Object declared in class AsyncTask
    Result extends Object declared in class AsyncTask
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object from capture of ?
Note: C:\Users\xx\xx\BarcodeEye\src\com\github\barcodeeye\scan\api\CardPresenter.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJava'.

Solution

  • Alright after taking a closer look at the AsyncTasks themselfs I figured out where the error was coming from.

    Apparently when converting the project to android studio it isn't taking the values for the asyncTask

    It was looking like this

    AsyncTask<?, ?, ?> someTask;
    

    I then went on and changed all the AsyncTask to hold the appropriate features.

    So if anyone else is experiencing this problem, check your AsyncTask identifier, this is what is causing the problem