【问题标题】:android studio getResources().getIdentifier return 0 if apply dexguard如果应用 dexguard,android studio getResources().getIdentifier 返回 0
【发布时间】:2015-07-21 10:04:53
【问题描述】:

我在应用程序中使用了 dexguard。我正在动态加载图像并在它的图像视图中显示。但图像视图显示空白。我正在使用下面的代码。

 getResources().getIdentifier(imagename, "drawable", packageName);

当我为我的项目使用 dexguard 1.7.0.02 时它返回 0(启用缩小并禁用混淆并优化调试构建)。如果我删除 dexguard 并运行项目,它工作正常并显示正确的图像。

注意:在 Eclipse 中与 dexguard 相同的项目,在上面的代码中工作正常。我只在 Android Studio 中遇到过这个问题。

【问题讨论】:

    标签: android android-studio android-drawable dexguard


    【解决方案1】:

    我自己找到了解决方案。如果你在 android studio 中应用收缩,dexguard 7.0 会收缩资源(对于未使用)。但是当我来到 Dexguard 6.0 时,它并没有收缩资源(我在 eclipse 项目中观察到)。所以我为 Dexguard 管理如下资源7.0配置

      -keepresourcefiles res/drawable/**
      -keepresources drawable/**
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多