Nick Palmer
Nick Palmer

Reputation: 2753

Android Studio: How to run a single test on x86

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

When I click on the "Run" icon, Android Studio ALWAYS builds and deploys the "Arm" flavor of our product. If I run this on an x86 emulator it fails because it doesn't have the libraries for x86.

Anybody know how to convince Android Studio to deploy the right version for a particular emulator?

Upvotes: 3

Views: 5709

Answers (2)

themenace
themenace

Reputation: 2800

Try using the abiFilter property in your build.gradle.

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

In Chapter Building one APK per architecture, and doing it well! it says:

Use flavors to build one APK per architecture really easily, by using abiFilter property.

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 might just need the arm & x86.

After this, synchronize the project with the gradle file using

Tools > Android > Sync Project with Gradle Files

Now you should be able to switch between build variants and one APK by architecture should be generated.

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

Hope this helps.

Upvotes: 5

Sean
Sean

Reputation: 5256

First of all, there's now an easier way to distribute to different ABI's without using flavours - 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

There 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 that will help you manage the tests easier

Upvotes: 0

Related Questions