English 中文(简体)
环境中的环境变化。 不与Series合作
原标题:Environment variable in settings.gradle not working with Android Studio

我确实有一个多功能项目,一个图书馆项目,其基础是不同的。 举例来说,你可以想象这样的情况:

/projects_home/projects/app_root
   |--app/
   |   |--build.gradle
   |--build.gradle
   |--settings.gradle

/libraries_home/libraries
   |--libA
       |--build.gradle

在我的情况下。 梯度档案 我能够利用项目Dir属性为图书馆项目确定绝对道路。 这部作品在奥塞罗内以及同陈列室一起进行。

但是,如果我试图利用一个环境变量,那么它就停止了与安眠素室合作。 这些环境。 上文例子的梯度就是这样:

include  :app 
include  :libA 

project( :libA ).projectDir = new File("$System.env.LIB_ROOT",  /libraries/libA )

如果我用青.素的梯度总结,它仍然奏效。 但是,AS公司停止使用下列错误:

Gradle  app  project refresh failed:
Configuration with name  default  not found.

如果我放弃环境变数,那么在奥塞罗的基础之上的建设就失败了同样的ms:

* What went wrong:
A problem occurred configuring project  :app .
> Configuration with name  default  not found.

因此,我猜测,AS在某种程度上无法利用我所设计的环境变量。

你们中有些人可能知道我如何能够让协会了解我的环境?

最佳回答

安德森·演播室用了环境变量,因此这种方法赢得了工作。 此外,如果使用<条码>项目Dir办法,dings.gradle,可能会造成问题。 安德列斯演播室有一个限制,即其所有单元都需要放在项目根基下。 如果你们有多个项目使用的图书馆,而且这些图书馆可能不会被置于单一项目根基之下,那么最好的建议是,让它们向当地Maven存放处公布联合提交书或联合提交书,供各个项目取用。

问题回答

安德森·演播室<改为环境变量。 可以通过发起“安乐施会”来证明这一点。

你没有这些变量的原因是,你使用的X-window环境没有读到包含这些变数的。 之所以如此,是因为<条码>bashrc适用于Bash not X。

假设你正在使用全球海洋观测系统或团结,则采用已指明的环境变数来发射陈词典,只是修改了<代码>desktop 安德斯温室文档(例如~/. local/comm/applications/android-studio.desktop <>/code>):

规定:

Exec="/home/username/tools/android/android-studio/bin/studio.sh" %f

修改如下:

Exec=env LIB_ROOT=/libraries_home "/home/username/tools/android/android-studio/bin/studio.sh" %f

注:

这一修改只是预设的<代码>env LIB_ROOT=/libraries_home。 您必须用自己的用户名称取代<代码>用户名<>。

<>Update>

如果有问题,请代替直接编辑回答。

在Macs,Adhurch没有读到环境变量,在Gradle明显使用。 我认为,这是这里答案的混淆原因——可能就在Windows上。

为了让Series读到环境变量,我从指挥线操作应用:

> /Applications/Android Studio.app/Contents/MacOS/studio 

这里的其他答案是使用环境变量以外的解决办法。 就我的情况而言,我用一个图书馆来书写,需要使用一个环境变量,而我却不编辑自己的代码,从而更便于日后更新。

EDIT: 而且,我有一只 do子,以这种方式发射陈象素:

尽管斯科特·巴塔的答复是正确的,但我认识到,如果其他人有同样的要求,可以解决我的问题,放弃分享。

I am now using the gradle.properties file do define and use gradle properties instead of system properties. The documentation of this feature can be fined in the user guide

解决我原来的问题的办法现在就是如此:

$USER_HOME/.gradle/gradle.properties:

LIB_ROOT=/libraries_home

The settings.gradle file has to be modified to use the gradle property instead of the system property:

include  :app 
include  :libA 

project( :libA ).projectDir = new File(LIB_ROOT,  /libraries/libA )

This works fine for me, headless as well as with AS.

Some more words regarding the fact that I am working with modules which are not placed underneath one project root. Till now it looks like AS is not complaining about this. But I just started working with this structure and it may be that I will run into problems later. What I like about this is the more flat representation in AS which is more like I am used to have it with Eclipse.

用户指南中还描述的是,将系统性能与梯度挂钩。 财产档案。 我也尝试了这一问题,但我确实在利用环境变量处理同样的问题。

It works for me with the following steps:

  1. Set your variable in Windows
  2. Reboot
  3. reach it in gradle build: System.env.MYVARIABLE

你们可以通过评估确定环境变量:

-DYOUR_VARIABLE=variable_value

~/Library/P参比/AndroidStudioX.X/studio.vmoptions 页: 1 Help -> Edit Customs RV Options... from Andersroom menu.

那么,你可以这样使用:

System.env.YOUR_VARIABLE

build.gradle或dings.gradle

在安莎·布卑贝雷更新后,我还面临着同样的问题。 之所以出现这种情况,是因为有人允许与Series公司接洽。

工作是增加失踪国旗:

chmod +x /Applications/Android Studio.app/Contents/bin/printenv

详情请查询

在麦克斯温斯·演播室,实际上在一段时间前就开始读过。 此前 但在进口这些var的过程中可能会出现错误。 https://youtro.jetbrains.com





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...