Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio(2.2.0 and 2.2.1) sends wrong ABI split to device

I'm using ABI splits in my app

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

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

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]

Edit : The way of how i'm getting this issue

  • I closed the x86_64 emulator
  • Connected real test device
  • Followed Run - Edit Configurations - Target (Open Select Deployment Target Dialog)
  • Chosed the connected test device

Android Studio 2.2.1

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,

added split section to gradle

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

created application class

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);
    }
}

selected my device

enter image description here

app worked, so studio sent appropriate apk(app-armeabi-v7a-debug.apk) to device

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

After all, i changed the 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);
    }
}

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

 $ adb push /home/blackkara/projects/Sample/app/build/outputs/apk/app-armeabi-debug.apk /data/local/tmp/com.blackkara.sample
like image 261
blackkara Avatar asked Sep 27 '16 14:09

blackkara


People also ask

How to change build variant in Android Studio?

Change the build variant By default, Android Studio builds the debug version of your app, which is intended for use only during development, when you click Run. To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar.

How to get debug APK in Android Studio?

To start debugging an APK, click Profile or debug APK from the Android Studio Welcome screen. Or, if you already have a project open, click File > Profile or Debug APK from the menu bar. In the next dialog window, select the APK you want to import into Android Studio and click OK.


1 Answers

According to Issue 215493 a fix has been released in Android Studio 2.2.1.

like image 158
Eugen Pechanec Avatar answered Nov 05 '22 01:11

Eugen Pechanec