android_intent首先安装Flutter插件出错
android_intent Error First Install Flutter Plugin
这是我第一次在我的应用程序中安装Android_intent插件,在实验过程中我在一个简单的应用程序中安装了插件并且插件运行良好,但是当我在应用程序中做同样的事情时我实际上有一个不再工作的插件。但是当我安装它时出现这样的错误:
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:23: error: duplicate class: io.flutter.plugins.androidintent.AndroidIntentPlugin
public class AndroidIntentPlugin implements MethodCallHandler {
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:13: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodCall;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:14: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodChannel;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:15: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:16: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.Result;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:17: error: package io.flutter.plugin.common.PluginRegistry does not exist
import io.flutter.plugin.common.PluginRegistry.Registrar;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:23: error: cannot find symbol
public class AndroidIntentPlugin implements MethodCallHandler {
^
symbol: class MethodCallHandler
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:25: error: cannot find symbol
private final Registrar mRegistrar;
^
symbol: class Registrar
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:28: error: cannot find symbol
public static void registerWith(Registrar registrar) {
^
symbol: class Registrar
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:34: error: cannot find symbol
private AndroidIntentPlugin(Registrar registrar) {
^
symbol: class Registrar
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:117: error: cannot find symbol
public void onMethodCall(MethodCall call, Result result) {
^
symbol: class MethodCall
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:117: error: cannot find symbol
public void onMethodCall(MethodCall call, Result result) {
^
symbol: class Result
location: class AndroidIntentPlugin
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:13: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodCall;
^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:14: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodChannel;
^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:15: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:16: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.Result;
^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:17: error: package io.flutter.plugin.common.PluginRegistry does not exist
import io.flutter.plugin.common.PluginRegistry.Registrar;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:29: error: cannot find symbol
final MethodChannel channel =
^
symbol: class MethodChannel
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:30: error: cannot find symbol
new MethodChannel(registrar.messenger(), "plugins.flutter.io/android_intent");
^
symbol: class MethodChannel
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:116: error: method does not override or implement a method from a supertype
@Override
^
20 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':android_intent: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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1
我已经试了好几天了。
我的代码错了吗?
有人能帮我吗?谢谢你
最好的问候。
将此代码添加到项目的 android 构建 Gradle 文件中。
subprojects {
project.evaluationDependsOn(':app')
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx')) {
details.useVersion "1.0.1"
}
}
}
}
重试前不要忘记清理项目。
我刚用另一个插件遇到了同样的问题,没有找到有用的信息。最终对我有用的步骤是:
升级gradle的版本:
- 在
android/gradle/wrapper/gradle-wrapper.properties
我切换到使用 5.4.1
- 在
android/build.gradle
我切换到classpath 'com.android.tools.build:gradle:3.5.1'
确保使用 AndroidX 支持库:
- 在
android/app/build.gradle
中,这是将所有 android.support
前缀切换为 androidx.support
(并且 com.android.support
分别切换为 com.androidx.support
)的问题。
根据我的实验,我认为问题的根本原因是 #2 - 事实上,步骤 #1 可能完全没有必要,但在我试图弄清楚时似乎是一个合理的起点问题是什么。
由于您没有提供有关您的 gradle 属性的信息,我只能根据遇到的构建问题的相似性假设您面临类似的问题。
这是我第一次在我的应用程序中安装Android_intent插件,在实验过程中我在一个简单的应用程序中安装了插件并且插件运行良好,但是当我在应用程序中做同样的事情时我实际上有一个不再工作的插件。但是当我安装它时出现这样的错误:
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:23: error: duplicate class: io.flutter.plugins.androidintent.AndroidIntentPlugin
public class AndroidIntentPlugin implements MethodCallHandler {
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:13: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodCall;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:14: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodChannel;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:15: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:16: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.Result;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:17: error: package io.flutter.plugin.common.PluginRegistry does not exist
import io.flutter.plugin.common.PluginRegistry.Registrar;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:23: error: cannot find symbol
public class AndroidIntentPlugin implements MethodCallHandler {
^
symbol: class MethodCallHandler
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:25: error: cannot find symbol
private final Registrar mRegistrar;
^
symbol: class Registrar
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:28: error: cannot find symbol
public static void registerWith(Registrar registrar) {
^
symbol: class Registrar
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:34: error: cannot find symbol
private AndroidIntentPlugin(Registrar registrar) {
^
symbol: class Registrar
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:117: error: cannot find symbol
public void onMethodCall(MethodCall call, Result result) {
^
symbol: class MethodCall
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:117: error: cannot find symbol
public void onMethodCall(MethodCall call, Result result) {
^
symbol: class Result
location: class AndroidIntentPlugin
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:13: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodCall;
^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:14: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodChannel;
^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:15: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:16: error: package io.flutter.plugin.common.MethodChannel does not exist
import io.flutter.plugin.common.MethodChannel.Result;
^
/home/denis/AndroidStudioProjects/spmi_conference/build/android_intent/generated/source/buildConfig/debug/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:17: error: package io.flutter.plugin.common.PluginRegistry does not exist
import io.flutter.plugin.common.PluginRegistry.Registrar;
^
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:29: error: cannot find symbol
final MethodChannel channel =
^
symbol: class MethodChannel
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:30: error: cannot find symbol
new MethodChannel(registrar.messenger(), "plugins.flutter.io/android_intent");
^
symbol: class MethodChannel
location: class AndroidIntentPlugin
/home/denis/Documents/DENISDATA/Jobs/2018/test/flutter/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.0+2/android/src/main/java/io/flutter/plugins/androidintent/AndroidIntentPlugin.java:116: error: method does not override or implement a method from a supertype
@Override
^
20 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':android_intent: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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1
我已经试了好几天了。 我的代码错了吗? 有人能帮我吗?谢谢你 最好的问候。
将此代码添加到项目的 android 构建 Gradle 文件中。
subprojects {
project.evaluationDependsOn(':app')
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx')) {
details.useVersion "1.0.1"
}
}
}
}
重试前不要忘记清理项目。
我刚用另一个插件遇到了同样的问题,没有找到有用的信息。最终对我有用的步骤是:
升级gradle的版本:
- 在
android/gradle/wrapper/gradle-wrapper.properties
我切换到使用 5.4.1 - 在
android/build.gradle
我切换到classpath 'com.android.tools.build:gradle:3.5.1'
- 在
确保使用 AndroidX 支持库:
- 在
android/app/build.gradle
中,这是将所有android.support
前缀切换为androidx.support
(并且com.android.support
分别切换为com.androidx.support
)的问题。
- 在
根据我的实验,我认为问题的根本原因是 #2 - 事实上,步骤 #1 可能完全没有必要,但在我试图弄清楚时似乎是一个合理的起点问题是什么。
由于您没有提供有关您的 gradle 属性的信息,我只能根据遇到的构建问题的相似性假设您面临类似的问题。