简体   繁体   English

Windows和Mac上的Android库项目

[英]Android Library Projects on Windows and Mac

I'm asking this question on behalf of my team of two Android devs. 我代表两个Android开发人员的团队问这个问题。 I use Windows and my partner uses a Macbook. 我使用Windows,而我的伴侣使用Macbook。 When sharing a project through Git, the classpaths accidentally got messed up. 通过Git共享项目时, classpaths偶然被弄乱了。 Here are a few observations: 以下是一些观察结果:

  • The library projects referenced (working initially) can't be resolved anymore. 引用的库项目(最初正在运行)无法再解决。
  • When adding through the Projects tab in 'Java Build Path', the libraries can be found. 通过“ Java构建路径”中的“项目”选项卡进行添加时,可以找到这些库。
  • But the app crashes (due to NoClassDefFoundError ), again pointing towards a messy build path structure. 但是该应用程序崩溃(由于NoClassDefFoundError ),再次指向混乱的构建路径结构。
  • Initially referenced library projects on the Mac used to appear directly in the build path as JARs. 在Mac上最初引用的库项目曾经直接以JAR的形式出现在构建路径中。 Now they do under Android Dependencies, which is weird (the former more). 现在他们在Android Dependencies下运行,这很奇怪(前者更多)。
  • On the Windows, the above JARs have always been under Dependencies and Referenced Libraries. 在Windows上,上述JAR始终位于“依赖关系”和“引用的库”下。

I'd like to resolve this issue in a way that we can share the project on Git and work seamlessly in the future. 我想以一种我们可以在Git上共享项目并在未来无缝运行的方式解决此问题。 :) :)

One option is to: 一种选择是:

  • not version .classpath , 不是版本.classpath
  • version a classpath template 版本化类路径模板
  • generate the right classpath depending on the current platform where the code is checked out. 根据签出代码的当前平台生成正确的类路径。

That is called a content filter driver , here a smudge script, which will be called automatically (hence the "seamless" aspect) on git checkout , and will generate the actual .classpath (otherwise not versioned and add in the .gitignore ) 这就是所谓的内容过滤器驱动程序 ,这里是smudge脚本,将在git checkout上自动调用(因此称为“无缝”方面),并将生成实际的.classpath (否则未版本化并添加.gitignore

http://git-scm.com/book/en/v2/book/08-customizing-git/images/smudge.png

(image shown in " Customizing Git - Git Attributes ", from " Pro Git book ") (图像显示在“ 自定义Git-Git属性 ”中,来自“ Pro Git书 ”)

Note that you can easily remove (without deleting it locally) the .classpath from the repo: 请注意,您可以轻松地从存储库中删除(无需在本地删除) .classpath

git rm --cached -- .classpath
git add -u .
git commit -m "Delete .classpath"
git push

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

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