我要
“任务执行失败':flutter_keyboard_visibility:compileDebugJavaWithJavac'”
构建项目时出错。我已经在这个项目上工作了一段时间,没有问题。我唯一要做的是flutter upgrade
。我没有添加,删除依赖项或其他任何内容。我现在在每个Flutter项目中都遇到这个问题。当我尝试构建和运行本机Android应用程序时,一切都按预期工作。我怀疑Flutter无法找到Android SDK或类似的软件,但我可以看到Android SDK的路径应该正确。以下是Android Studio给我的错误的完整版本。
Running Gradle task 'assembleDebug'...
error: error reading /Users/sametsahin/.gradle/caches/modules-2/files-2.1/io.flutter/flutter_embedding_debug/1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695/469d369e7a7ea2b0f6b2822cfc8a6ec0cc99e962/flutter_embedding_debug-1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695.jar; error in opening zip file
error: error reading /Users/sametsahin/.gradle/caches/modules-2/files-2.1/io.flutter/flutter_embedding_debug/1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695/469d369e7a7ea2b0f6b2822cfc8a6ec0cc99e962/flutter_embedding_debug-1.0.0-2994f7e1e682039464cb25e31a78b86a3c59b695.jar; error in opening zip file
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:11: error: package io.flutter.app does not exist
import io.flutter.app.FlutterActivity;
^
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:12: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.EventChannel;
^
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:13: error: package io.flutter.plugin.common.EventChannel does not exist
import io.flutter.plugin.common.EventChannel.EventSink;
^
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:14: error: package io.flutter.plugin.common.EventChannel does not exist
import io.flutter.plugin.common.EventChannel.StreamHandler;
^
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:15: error: package io.flutter.plugin.common.PluginRegistry does not exist
import io.flutter.plugin.common.PluginRegistry.Registrar;
^
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:18: error: cannot find symbol
public class KeyboardVisibilityPlugin implements StreamHandler, Application.ActivityLifecycleCallbacks, ViewTreeObserver.OnGlobalLayoutListener {
^
symbol: class StreamHandler
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:21: error: cannot find symbol
EventSink eventsSink;
^
symbol: class EventSink
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:22: error: cannot find symbol
Registrar registrar;
^
symbol: class Registrar
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:26: error: cannot find symbol
KeyboardVisibilityPlugin(Registrar registrar) {
^
symbol: class Registrar
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:100: error: cannot find symbol
public static void registerWith(Registrar registrar) {
^
symbol: class Registrar
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:113: error: cannot find symbol
public void onListen(Object arguments, final EventSink eventsSink) {
^
symbol: class EventSink
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:57: error: cannot find symbol
if (activity instanceof FlutterActivity) {
^
symbol: class FlutterActivity
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:77: error: cannot find symbol
if (activity instanceof FlutterActivity) {
^
symbol: class FlutterActivity
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:88: error: cannot find symbol
if (activity instanceof FlutterActivity) {
^
symbol: class FlutterActivity
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:102: error: cannot find symbol
final EventChannel eventChannel = new EventChannel(registrar.messenger(), STREAM_CHANNEL_NAME);
^
symbol: class EventChannel
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:102: error: cannot find symbol
final EventChannel eventChannel = new EventChannel(registrar.messenger(), STREAM_CHANNEL_NAME);
^
symbol: class EventChannel
location: class KeyboardVisibilityPlugin
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:112: error: method does not override or implement a method from a supertype
@Override
^
/Users/sametsahin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-0.7.0/android/src/main/java/com/flutter/keyboardvisibility/KeyboardVisibilityPlugin.java:123: error: method does not override or implement a method from a supertype
@Override
^
18 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_keyboard_visibility: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. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
Finished with error: Gradle task assembleDebug failed with exit code 1
当我检查在danef_dictionary / android / app / build.gradle中找到的build.gradle文件时 我意识到GradleException是红色的,并说
无法解析符号“ GradleException”
当我将鼠标悬停在上面时。 我该怎么办?
答案 0 :(得分:0)
我通过以下更改解决了我的问题:
在Android build.gradle中
已变更
类路径'com.android.tools.build:gradle:3.2.1'
至
类路径'com.android.tools.build:gradle:3.5.3'
已更改
ext.kotlin_version = '1.2.71'
到
ext.kotlin_version = '1.3.50'
在android / gradle / wrapper / gradle-wrapper.properties中
已更改
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
到
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip