Android Studio: how to run one test on x86

I am using two different flavors for two different architectures because I have very large native libraries and I need smaller binaries.

When I click the Run icon, Android Studio ALWAYS builds and deploys the "Arm" flavor of our product. If I run it on an x86 emulator it fails because it has no x86 libraries.

Does anyone know how to convince Android Studio to deploy the correct version for a specific emulator?

+3


source to share


2 answers


Try using property abiFilter

in build.gradle file.

This post explains how to use native libraries across different architectures:

In the chapter Create one APK for each architecture and do it well! :

It is very easy to use flavors to create one APK for architecture using the property abiFilter

.

Try adding this to your gradle.build:

android{
  ...
  productFlavors {
        x86 {
            ndk {
                abiFilter "x86"
            }
        }
        mips {
            ndk {
                abiFilter "mips"
            }
        }
        armv7 {
            ndk {
                abiFilter "armeabi-v7a"
            }
        }
        arm {
            ndk {
                abiFilter "armeabi"
            }
        }
        fat
    }
}

      



You may only need arm

and x86

.

After that sync the project with the gradle file using

Tools > Android > Sync Project with Gradle Files

      

You should now be able to switch between build options and one APK by architecture.

Select Build Variants

in the lower left corner. You should be able to switch between different architectures in the Build Variant dropdown.

Hope it helps.

+5


source


First of all, there is now an easier way to distribute different ABIs without using flavors - this is new to Android gradle 0.13.0 (2014/09/18)

- http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits

It says: Using the new Split mechanism, building a hdpi, and an mdpi version of the same app will share a lot of the tasks (like javac, dx, proguard). Additionally, it will be considered a single variant and the same test app will be used to test every multi-apk.



Maybe it will help you deal with testing easier.

0


source







All Articles