项目从 eclipse 运行,但是当导出到 gradle 时异步抛出错误

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

我正在尝试让 BarcodeEye 在我自己的项目中工作。 当我在 eclipse 中导入项目并尝试 运行 它工作得很好。

然后我在 android studio 中尝试了以下 3 种获取它的方法。

  1. 首先,我将现有项目所需的所有文件复制到我自己的项目中。在设置了所有正确的导入和包名称后,我在尝试构建它时遇到了 4 个错误(下面会出现 post 错误)
  2. 我直接在android工作室打开eclipse工程,尝试build。我有 4 个错误(见下文)
  3. 我将 eclipse 项目导出到 gradle,然后在 android studio 中打开它。我再次遇到 4 个错误。

有人知道这里出了什么问题吗?

错误

    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'.

好吧,在仔细查看 AsyncTasks 他们自己之后,我弄清楚了错误的来源。

显然,在将项目转换为 android 工作室时,它没有采用 asyncTask

的值

看起来像这样

AsyncTask<?, ?, ?> someTask;

然后我继续更改所有 AsyncTask 以包含适当的功能。

因此,如果其他人遇到此问题,请检查您的 AsyncTask 标识符,这就是导致问题的原因