Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle using different abiFilters for debug and release

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.

like image 626
Makalele Avatar asked Jan 13 '17 08:01

Makalele


1 Answers

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"
        }
    }
  }
}
like image 68
Alex Cohn Avatar answered Oct 20 '22 17:10

Alex Cohn