How to put specific classes into main DEX file?

前端 未结 4 672
隐瞒了意图╮
隐瞒了意图╮ 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:29

    With Android Plugin for Gradle, Revision 2.2.0 (Released in September 2016) you can use multiDexKeepFile api

    android {
        buildTypes {
            debug {
                ...
                multiDexEnabled true
                multiDexKeepFile file('multidex_keep_file.txt')
            }
        }
    }
    

    Where multidex_keep_file.txt is file with single class per line which needs to be explicitly added to the main dex

     com/example/MyClass.class
     com/example/MyClass2.class
    

    You can also use multiDexKeepProguard to keep whole package

    -keep class com.example.** { *; }
    

提交回复
热议问题