Android Studio 向Flutter项目添加运行/调试配置环境变量?

lnvxswe2  于 2022-11-16  发布在  Android
关注(0)|答案(1)|浏览(188)

我尝试在Android Studio的flutter项目中将环境变量添加到运行/调试配置中,但该字段显示为灰色,而且我不知道如何创建环境变量。您知道如何以这种方式或其他方式添加环境变量吗?
A picture of my Run/Debug cConfigurations where the Environment variables are greyed out

fcwjkofz

fcwjkofz1#

不建议使用的方法是编辑flutter文件(脚本文件:Unix:bash,Windows:bat). see here的文件夹
我使用的是linux,我遇到了一个应用程序规模的问题(因为我使用的是hidpi屏幕),解决这个问题最简单的方法可能是设置环境变量GDK_SCALE=2。经过一番努力,我最终编辑了flutter源文件,如下所示:

#!/usr/bin/env bash
# Copyright 2014 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

export GDK_SCALE=2
# ---------------------------------- NOTE ---------------------------------- #
#
# Please keep the logic in this file consistent with the logic in the
# `flutter.bat` script in the same directory to ensure that Flutter continues

# ... [content omitted] ...

如果你想在开始一个新项目时改变环境变量,请考虑RUN confiugration中的before launch选项,你可以在运行当前配置之前运行其他配置。理想的运行顺序是运行delete environment variable lines配置(Shell脚本类型),在此之前执行(发布前)flutter run配置,之前执行(发布前)add environment variable lines配置(Shell脚本类型)。(共3个按顺序链接的配置文件)它还应显示flutter调试窗口,因为此选项存在于flutter run配置中。
我尝试过的其他方法:
1.设置全局环境(所有应用程序规模均已更改)
1.修改Android Studio桌面文件(Android Studio大小已更改)
1.破解android studio运行配置(如$(export x=1)以执行命令,但失败)

相关问题