Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove x86_64 package from Realm

Tags:

android

realm

I'm working with AS and I don't need the x86_64 package in realm. The x86_64 package cause some problems with other libs. How to remove the package?

enter image description here

like image 452
冯超群 Avatar asked Sep 02 '25 04:09

冯超群


2 Answers

abiFilters will be a good solution. The method will limit the abi and only add the specified abi when building the apk.

defaultConfig {
    applicationId "com.example.app"
    minSdkVersion 16
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi", "armeabi-v7a", "x86"
    }
// ...
}

This means only those specified arch-folders will be used and the rest can be deleted.

like image 132
冯超群 Avatar answered Sep 04 '25 18:09

冯超群


Well, you can remove any of the architecture folders, but keep in mind, that means the library in question (this case it's realm) will not work on those architectures that you remove.

To be frank, you can just simply remove it, but as I mentioned above, that is no good.

You can include/exclude different architectures from your build by a technique called splitting:

android {
    // Rest of Gradle file
        splits {
            abi {
            enable true
            reset()
            include 'armeabi', 'armeabi-v7a', 'arm64_v8a', 'mips', 'x86'
            universalApk true
        }
    }
}

//Ensures architecture specific APKs have a higher version code
//(otherwise an x86 build would end up using the arm build, which x86 devices can run)
ext.versionCodes = [armeabi:1, 'armeabi-v7a':2, 'arm64-v8a':3, 'mips':4, x86:5]

android.applicationVariants.all { variant ->
    // assign different version code for each output
    variant.outputs.each { output ->
        int abiVersionCode = project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
        output.versionCodeOverride = (abiVersionCode * 10000) + android.defaultConfig.versionCode
    }
}
like image 28
anthonymonori Avatar answered Sep 04 '25 19:09

anthonymonori



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!