简体   繁体   English

如何在 Android Studio 的版本控制项目中共享运行/调试配置?

[英]How to share Run/Debug Configurations in a version controlled project in Android Studio?

This should be really easy but for some reason I can't get it working.这应该很容易,但由于某种原因我无法让它工作。 Google/Android Studio guys recommend to avoid having .idea and *.iml files under version control and use "Import project" instead. Google/Android Studio 人员建议避免将 .idea 和 *.iml 文件置于版本控制之下,而是使用“导入项目”。 Works fine, no problem.工作正常,没问题。

However, if I want to share a run/debug configuration, I check the "Share" checkbox in the "Run/Debug Configurations" dialog which in turn creates .idea/configurations/name.xml.但是,如果我想共享运行/调试配置,我会选中“运行/调试配置”对话框中的“共享”复选框,这将创建 .idea/configurations/name.xml。 All right, let's put an exception in .gitignore for this file.好的,让我们在 .gitignore 中为这个文件设置一个例外。

Now, what happens:现在,会发生什么:

  1. git checkout (gradle files + .idea/configurations/name.xml) git checkout(gradle 文件 + .idea/configurations/name.xml)
  2. Import project (all the .idea and *.iml files are generated)导入项目(生成所有.idea和*.iml文件)
  3. Run -> Edit Configurations... -> do I see the shared configuration there?运行 -> 编辑配置... -> 我在那里看到共享配置了吗? Nope!不!

It's because the configuration must be referenced by .idea/workspace.xml file.这是因为配置必须被 .idea/workspace.xml 文件引用。 But everyone recommends to avoid having this file versioned because it contains user settings so it should be generated automatically.但是每个人都建议避免对这个文件进行版本控制,因为它包含用户设置,所以它应该自动生成。

So how to solve this chicken-egg problem?那么如何解决这个先有鸡下蛋的问题呢?

For me it was enough to add the "runConfigurations" folder to version control.对我来说,将“runConfigurations”文件夹添加到版本控制就足够了。

All Configurations have to have "Share" checked as to provide a seperate file for them.所有配置都必须选中“共享”,以便为它们提供单独的文件。

Then once project is checked out all configurations are runnable again.然后一旦项目被检出,所有配置都可以再次运行。

This works perfectly in Android Studio 3.5.3.这在 Android Studio 3.5.3 中完美运行。 (With my flutter repository) (使用我的颤振存储库)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM