Android studio(2.2.0 and 2.2.1) sends wrong ABI split to device
<p>I'm using ABI splits in my app</p>

<pre><code>splits {
    abi {
        enable true
        reset()
        include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips'
        universalApk true
    }
}
</code></pre>

<p>If i use a x86_64 emulator then switch to device (armeabi-v7a) (and also others), android studio sends app-x86_64-debug.apk to device</p>

<pre><code>09/27 17:17:49: Launching app
$ adb push SampleFolder\app\build\outputs\apk\app-x86_64-debug.apk /data/local/tmp/sample.package
$ adb shell pm install -r "/data/local/tmp/sample.package"
pkg: /data/local/tmp/sample.package
Failure [INSTALL_FAILED_NO_MATCHING_ABIS]
</code></pre>

<p>Edit : <strong>The way of how i'm getting this issue</strong></p>

<ul>
<li>I closed the x86_64 emulator </li>
<li>Connected real test device</li>
<li>Followed Run - Edit Configurations - Target (Open Select Deployment Target Dialog)</li>
<li>Chosed the connected test device</li>
</ul>

<p><strong>Android Studio 2.2.1</strong></p>

<p>After releasing the 2.2.1, i had played a bit split distributions then everything was looking good. Unfortunately same problem happened to me again. To be make sure clearly, i created new android project and imported realm database (has native libraries) and then,</p>

<p>added split section to gradle</p>

<pre><code> splits {
    abi {
        enable true
        reset()
        include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips'
    }
}
</code></pre>

<p>created application class</p>

<pre><code>public class SampleApp extends Application {

    @Override
    public void onCreate() {
        initRealm();
    }

    private void initRealm(){
        Realm.init(getApplicationContext());
        RealmConfiguration.Builder builder = new RealmConfiguration.Builder();
        builder.deleteRealmIfMigrationNeeded();
        RealmConfiguration configuration = builder.build();
        Realm.setDefaultConfiguration(configuration);
    }
}
</code></pre>

<p>selected my device</p>

<p><a href="https://i.stack.imgur.com/K41k5.png" rel="nofollow"><img src="https://i.stack.imgur.com/K41k5.png" alt="enter image description here"></a></p>

<p><strong>app worked, so studio sent appropriate apk(app-armeabi-v7a-debug.apk) to device</strong></p>

<pre><code>$ adb push /home/blackkara/projects/Sample/app/build/outputs/apk/app-armeabi-v7a-debug.apk /data/local/tmp/com.blackkara.sample
</code></pre>

<p>After all, i changed the code</p>

<pre><code>public class SampleApp extends Application {

    @Override
    public void onCreate() {
        initRealm();

        // The added code
        Realm realm = Realm.getDefaultInstance();
    }

    private void initRealm(){
        Realm.init(getApplicationContext());
        RealmConfiguration.Builder builder = new RealmConfiguration.Builder();
        builder.deleteRealmIfMigrationNeeded();
        RealmConfiguration configuration = builder.build();
        Realm.setDefaultConfiguration(configuration);
    }
}
</code></pre>

<p><strong>then ran app again, but this time studio sent wrong apk(app-armeabi-debug.apk) to device</strong></p>

<pre><code> $ adb push /home/blackkara/projects/Sample/app/build/outputs/apk/app-armeabi-debug.apk /data/local/tmp/com.blackkara.sample
</code></pre>