Search code examples
codenameone

Inject additional attributes into the defaultConfig tag in the Android build.gradle


I need to inject:

ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
        }

to get something like:

android {

    [...] 

    defaultConfig {
        applicationId "app.myapp.client"
        minSdkVersion 24
        targetSdkVersion 29
        versionCode 100
        versionName "1.0"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
        }
    }

    [...]

I've already tested in Android Studio that this solves the bug: https://github.com/codenameone/CodenameOne/issues/3377

The reason is explained here: https://medium.com/mobiwise-blog/unsatisfiedlinkerror-problem-on-some-android-devices-b77f2f83837d

but I didn't find a build hint to achieve this automatically. Which one can I use?


Solution

  • You can use the build hint:

    android.xgradle_default_config=ndk { abiFilters "armeabi-v7a", "x86", "armeabi", "mips"; }