Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter 踩中的坑 #33

Open
Leo-lin214 opened this issue Sep 11, 2020 · 1 comment
Open

Flutter 踩中的坑 #33

Leo-lin214 opened this issue Sep 11, 2020 · 1 comment

Comments

@Leo-lin214
Copy link
Owner

相信各位在 Flutter 的开发中都踩过形形色色的坑,特别是构建环境,以下我也稍微总结一下自己在开发过程中遇到的一些小坑,方便日后遇到能够更快捷滴进行处理。

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

在构建安卓 Flutter 应用时,就遇到了这个错,网上处理的方式大概有三种,以 Mac 为例:

  1. 删掉项目中/android/.gradle文件,然后执行flutter clean

  2. Flutter安装目录下的Flutter/packages/flutter_tools/gradle/flutter.gradle文件中,将以下内容进行替换:

    private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com"
    
    // 替换成
    private static final String DEFAULT_MAVEN_HOST = "https://storage.flutter-io.cn/download.flutter.io"
  3. 依然是上述2种文件,将以下内容进行替换:

    buildscript {
        repositories {
            google()
            jcenter()
        }
      	// ...
    }
    
    // 替换成
    buildscript {
        repositories {
            // google()
            // jcenter()
          	maven { url 'https://maven.aliyun.com/repository/google' }
            maven { url 'https://maven.aliyun.com/repository/jcenter' }
            maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
        }
      	// ...
    }

其实第2、第3种方案都是为了解决科学上网问题,将资源获取更换为国内代理。

但很不幸的是,试完了以上方法我依然无法得到解决!!!

最后一种方案就是,在项目文件中/android/build.gradle,增加如下代码

allprojects {
    repositories {
        google()
        jcenter()
    }
}

// 增加代码
allprojects {
    repositories {
        google()
        jcenter()
        maven { url "http://download.flutter.io" }
    }
}

最后终于得到了解决~。

avdmanager is missing from the android sdk

在使用vscode开发Flutter时,当想启动安卓应用来跑程序,发现报了上面那个错。

这是因为,以 Mac 为例,有些童鞋在安装android sdk时可能会配置在~/.bash_profile,也可能配置在~/.zshrc,因此一定要细心查究

我就是上面两个配置不一致,才导致了问题出现。

解决方案就是,可以通过命令:

flutter config --android-sdk 安卓SDK安装的目录

只需要指定你安装好的android sdk目录位置,就可以唤起来


持续更新中~当然我也欢迎你们能够在评论区分享你们所遇到的坑啦👏

@oblivioussing
Copy link

avdmanager is missing from the android sdk 被这个问题搞了一个多小时,感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants