How to put specific classes into main DEX file?

前端 未结 4 778
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 17:50

We found an issue on Amazon market that IAP doesn\'t work if it\'s receivers located not in main DEX file. The question is how to force gradle

4条回答
  •  执笔经年
    2021-02-02 18:30

    Sergii Pechenizkyi's answar only keep some class in main dex , but not generate two dex. Add --minimal-main-dex to your builg.gradle. But this only solve below gradle1.5.0. You can use DexKnifePlugin to solve your problem.

    afterEvaluate {
        tasks.matching {
            it.name.startsWith('dex')
        }.each { dx ->
            if (dx.additionalParameters == null) {
                dx.additionalParameters = []
            }
        dx.additionalParameters += '--multi-dex'
        dx.additionalParameters += "--main-dex-list=class_files.txt" 
        dx.additionalParameters += '--minimal-main-dex'
        }
    }
    

提交回复
热议问题