无法解析符号FlutterActivity [英] Cannot resolve symbol FlutterActivity

查看:91
本文介绍了无法解析符号FlutterActivity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用"VCS->从版本控制中检出"从github将flutter项目导入了Android Studio.现在,我面临的问题是:Android的MainActivity.java中的无法解析符号FlutterActivity .

I imported flutter project from github into Android Studio with 'VCS -> Checkout from Version Control'. And now I'm facing the issue: Cannot resolve symbol FlutterActivity in android's MainActivity.java.

我用 New Flutter Project 向导创建了另一个Flutter项目.而且没有那种问题.这两个项目之间的区别在于,来自github的项目没有 External Libraries/Flutter for Android/flutter.jar ,而从头开始创建了.

I created another flutter project with New Flutter Project wizard. And there was no that kind of issue. The difference between the two projects was that the project from github didn't have External Libraries/Flutter for Android/flutter.jar whereas created from scratch one had.

我比较了两个项目的pubspec.yaml和build.gradle文件,没有发现与该依赖项相关的任何内容.

I compared pubspec.yaml and build.gradle files of both projects and didn't find anything that looks like related to that dependency.

这是相关项目的pubspec.yaml:

Here the pubspec.yaml of the project in question:

name: utopian_rocks_mobile
description: A new Flutter project.

version: 1.0.0+1

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  http: ^0.12.0
  rxdart: ^0.19.0
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter


flutter:

  uses-material-design: true

应该如何在扑朔迷离的项目中处理这种依赖性?

How that kind of dependency supposed to be handled in a flutter project?

推荐答案

使用flutter创建项目时,请在ios/和android/子目录中创建多个文件.

When a project is created with flutter create foo several files in the ios/ and android/ sub-directories are created.

较新的Flutter版本可能会生成这些文件,并且使用较旧的Flutter版本创建的项目可能会导致问题.

Newer Flutter versions might generate these files a bit differently and projects created with older Flutter versions might cause issues.

修复方法
删除 ios/和/或 android/目录,然后运行 flutter create.重新生成这些目录.

Ways to fix
Delete the ios/ and/or android/ directories and run flutter create . to re-generate these directories.

提示
自定义更改将丢失,需要重新应用.如果将项目提交到版本控制系统(如Git),这是最简单的.

Hint
Custom changes will be lost and need to be re-applied. This is easiest if the project is committed to a version control system like Git.

这篇关于无法解析符号FlutterActivity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆