When I try to run my application from the IDE on an x86 emulator I get an error "Application Installation Failed" with the message
Failed to finalize session: INSTALL_FAILED_TEST_ONLY: installackageLI
As I understand this error is because Android Studio automatically adds the android:testOnly="true" manifest attribute on all debug builds which requires adb install to use the -t flag to install the apk. This flag should not however be required when running from the IDE itself.
If I add the -t flag in Install Flags in my build configuration the apk can be installed, though only if Instant Run is disabled (and only if I do a clean build if it was previously enabled). Re-enabling Instant Run produces the same error even when including the -t flag.  
UPDATE:
The above occurs only when using android gradle plugin version 3.0.0.
When I revert to version 2.3.0 the problem disappears.
UPDATE 2:
This is related to IntelliJ IDE.
Android Studio 3.0 works fine with my configuration.
See the answers in this post.