问题描述
因此,我一直在尝试将多项目(即 Eclipse 项目)应用程序的开发迁移到 Android Studio (v1.1).
So, I have been trying to migrate the development of a multi-project (eclipse projects that is) app to Android Studio (v1.1).
通过文件导入 > 导入项目非常简单,而且没有发生任何意外.
Importing via File > Import Project was really easy and went without incident.
然而,当我尝试 Make/Rebuild 项目时,我遇到了许多惊喜.第一个,与 Proguard 无关,与源文件编码有关(最初在 Windows-1252 中),但我很快找到了使用这个 Windows-1252 > 重新加载 > UTF-8 > 转换 答案.
However, when I tried Make/Rebuild project I encountered numerous surprises. The first, not Proguard-related, had to do with source file encoding (originally in Windows-1252), but I quickly found a solution using this Windows-1252 > Reload > UTF-8 > Convert answer.
然后,我的 com.comp.mod.X
类的错误:找不到符号类".然后我通过转到包含该类的模块(Android Studio 模块,即以前的 Eclipse 项目)解决了这个问题,并将以下内容添加到其 proguard.cfg:
Then, "error: cannot find symbol class" for a com.comp.mod.X
class of mine. I then solved it by going to the module (Android Studio module that is, previously an Eclipse project) that contains that class and added to its proguard.cfg the following:
-keep public class com.comp.mod.X
对于在上述类中定义的 const BB,这给我留下了错误:找不到符号变量".我通过向相同的 proguard.cfg 添加以下内容解决了这个问题:
Which left me with an "error: cannot find symbol variable" for a const BB defined in the aforementioned class. I solved this by adding to the same proguard.cfg the following:
-keepclassmembers class com.comp.mod.X {
public static final boolean BB;
}
这让我只剩下一个错误:找不到符号方法 getPreferenceX()".我通过添加到相同的 -keepclassmembers 方法来解决这个问题,这样上面现在看起来:
That left me with only one "error: cannot find symbol method getPreferenceX()". I solve this by adding to the same -keepclassmembers that method, so that the above now looks:
-keepclassmembers class com.comp.mod.X {
public static final boolean BB;
public static java.lang.String getPreferenceX();
}
我以为我已经完成了,但令我沮丧的是,当我尝试重建项目时,我收到了来自项目中其他模块的许多额外错误,所有类型都为错误:找不到符号类/变量/方法" 并且与一些 proguard.cfg 相关.
I thought I was done, but to my dismay, when I attempted to rebuild the project, I received numerous additional errors from other modules in the project, all of the type to "error: cannot find symbol class/variable/method" and related to some proguard.cfg.
我本可以继续为每个模块删除 proguard.cfg 文件,但此时我开始怀疑我在做一些根本错误的事情,因为这些 proguard.cfg 文件在 Eclipse 下运行良好.所以,
I could have continued butchering the proguard.cfg files for each and every module but at this point I am beginning to suspect that I am doing something fundamentally wrong, because those proguard.cfg files work perfectly under Eclipse. So,
- 为什么突然间这些对 Android Studio 不再有用?
- 如果 ProGuard 仅在您在 发布版 模式,为什么基于 Android Studio 的构建会因为 Proguard 的混淆而抱怨找不到符号"?
我错过了什么?
注意:我未尝试生成签名的 APK".我所做的只是重建项目".
Note: I have not attempted "Generate Signed APK". All I do is "Rebuild Project".
推荐答案
目前(截至 2015-04-24),minifyEnabled
的默认值为 false
多模块项目的所有构建类型都不正确,其中一些模块(包括应用程序)依赖其他模块.这是由于 错误 #52962 导致构建类型不传播到库——它们总是被构建为 RELEASE.
Currently (as of 2015-04-24), minifyEnabled
's default value of false
for all build types is incorrect for multi-module projects, in which some modules (app included) are dependent on other modules. This is due to bug #52962 that causes build types to not propagate to libraries -- they are always built as RELEASE.
欢迎提出解决此错误的建议或对其修复的通知.
Suggestions to work around this bug or notifications of its fix are most welcome.
这篇关于从 Eclipse 到 Android Studio:为什么在不构建 Release 时使用 proguard.cfg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!