我不明白为什么会出现这个错误。我正在另一台计算机上编译并且发布编译没问题,但是在这台计算机上,我得到了:
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:app:preBuild
:app:preReleaseBuild
:app:checkReleaseManifest
:app:preDebugBuild
:app:prepareComAndroidSupportAppcompatV71910Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices4323Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:mergeReleaseAssets
:app:processReleaseManifest
:app:crashlyticsCleanupResourcesRelease
:app:crashlyticsUploadStoredDeobsRelease
:app:crashlyticsGenerateResourcesRelease
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseResources
:app:generateReleaseSources
:app:compileReleaseJava
/Users/wimha/wimhaAndroidApp/app/src/main/java/com/google/zxing/client/android/camera/AutoFocusManager.java:63: 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 ?
/Users/wimha/wimhaAndroidApp/app/src/main/java/com/google/zxing/client/android/InactivityTimer.java:52: 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 ?
/Users/wimha/wimhaAndroidApp/app/src/main/java/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 ?
3 errors
:app:compileReleaseJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileReleaseJava'.
> 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.
BUILD FAILED
Total time: 1 mins 56.213 secs
有什么想法吗?
答案 0 :(得分:2)
卸载Java 8解决了它。
答案 1 :(得分:2)
您不需要卸载Java 8.只需打开“项目结构”(Ctrl + alt + shift + s),选择“SDK Location”并将“JDK location”设置为JDK 7的路径。
答案 2 :(得分:1)
我通过替换像这样的匿名声明解决了
private AsyncTask<?, ?, ?> outstaindingTask;
与实际类型:
private AsyncTask<Object, Object, Object> outstandingTask;
您可以通过查看已实例化的类定义来查找要使用的类型列表,例如在AutoFocusManager
的情况下:
outstandingTask = new AutoFocusTask();
AutoFocusTask
类声明为:
private final class AutoFocusTask extends AsyncTask<Object,Object,Object>
答案 3 :(得分:0)
我不确定你是如何编译这段代码的,但它作为Java代码是正确的。它与Maven构建编译良好。这似乎是您正在使用的编译器中的错误。