簡體   English   中英

Multidex Android庫模塊

[英]Multidex Android Library Module

我在gradle項目中有一個已連接Android測試的庫模塊,但測試APK引用了太多方法,需要進行多索引或應啟用ProGuard。

有沒有辦法為連接的Android測試應用程序啟用multidex或ProGuard?

直接在庫上啟用ProGuard是沒有意義的,但如果有一種方法只能為androidTest配置啟用它,那就可以很好地工作。

我們確實為應用程序模塊啟用了ProGuard,因此它可以安全地依賴於此庫模塊並成功構建應用程序的APK。

由於我只能找到有關使用Multidex支持庫的信息,因此很難搜索此問題的解決方案。 我了解如何為典型應用程序啟用它。

有沒有辦法為連接的Android測試應用程序啟用multidex或ProGuard?

是的,您只能為使用專用測試構建類型的測試啟用ProGuard。 默認的是debug 在以下示例中,專用測試構建類型名為minifiedTest

android {

    defaultConfig {

        /* Your configs here. */

        // Specify the name of the dedicated test build type.
        testBuildType 'minifiedTest'
    }

    buildTypes {
        debug {
            // Your debug configurations.
        }

        release {
            // Your release configurations.
        }

        minifiedTest {
            // Use this to get the initial configurations from another build type.
            // Some of them will be overridden from the configurations specified in this build type.
            // You can avoid to use this or you can get them from your release build type for example.
            initWith(debug)
            // Enable proguard.
            minifyEnabled true
            // Specify the proguard file.
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM