【问题标题】:Why is Android Instant Run recompiling almost every time?为什么 Android Instant Run 几乎每次都重新编译?
【发布时间】:2016-03-10 15:10:17
【问题描述】:

我正在测试 Android Instant Run。为了测试,我刚刚在我的 Activity 的 onResume() 中添加了以下行:

Toast.makeText(this, "test123", Toast.LENGTH_SHORT).show();

现在,当我更改 toast 的文本并重建时,它会告诉我

"Instant Run detected that a resource referenced from the AndroidManifest.xml file has changed"

谁能解释这里发生了什么?我没有更改任何资源,只是 Activity java 文件中的字符串文字。 (我知道我应该在 Android btw 中使用字符串资源)。

【问题讨论】:

    标签: android android-studio android-build instant-run


    【解决方案1】:

    似乎问题在于我的 build.gradle 修改了 Android Manifest:

    debug {
        ...
        def theVersionNameSuffix = "-debug-" + getCurrentDateTimeString();
        versionNameSuffix theVersionNameSuffix
        ...
    }
    

    由于每个构建的后缀都不同,这意味着版本名称在构建之间发生变化,这会改变 AndroidManifest。

    我已经删除了 versionNameSuffix 条目,现在它似乎可以工作了。

    【讨论】:

    • 这也是我们遇到的问题。我们的解决方法是将时间戳保留在一种风格中,并将其从另一种风格中删除(需要 jRebel 提供)。 debug { productFlavors.dev.versionNameSuffix "." + getTimestampText(); productFlavors.fast.versionNameSuffix ".fast"; ... }
    猜你喜欢
    • 2013-05-20
    • 2021-02-25
    • 1970-01-01
    • 2020-10-17
    • 2021-01-25
    • 1970-01-01
    • 2013-08-19
    • 2022-07-23
    • 2022-09-27
    相关资源
    最近更新 更多