7
votes

here's a piece of my build.gradle file:

android {
    //...

    defaultConfig {
        //...

        externalNativeBuild {

                ndkBuild {
                    targets "MyGame"
                    arguments "NDK_MODULE_PATH=$cocospath:$cocospath/cocos:$cocospath/external:$cocospath/cocos/prebuilt-mk:$cocospath/extensions"
                    arguments "-j" + Runtime.runtime.availableProcessors()

                    buildTypes {
                        debug {
                            abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
                        }

                        release {
                            abiFilters "armeabi"
                        }
                    }

                }
        }
    }
    //.........

I'm trying to use three abi filters (armeabi, armeabi-v7a and arm64-v8a) while building app in debug mode and use only one (armeabi) while building release apk. But it doesn't work. Either debug and release version are using all three abiFilters.

What's wrong with my gradle file?

edit:

It turns out when I had all three abi filters and successfully build app I wanted to leave just armeabi and... still all three were added. I had to manually delete contents of app/build directory.

1

1 Answers

16
votes

You put your aabiFIlters in a wrong block. This is how it will work:

android {
  //...

  defaultConfig {
    //...

    externalNativeBuild {
      ndkBuild {
         targets "MyGame"
         arguments …
      }
    }
  }

  buildTypes {
    release {
       ndk {
            abiFilters "armeabi-v7a"
        }

        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        ndk {
            abiFilters "x86", "armeabi-v7a"
        }
    }
  }
}