Releasable APK can’t be installed? — Strange App launcher behaviors (part 3)

I didn’t get to know this until recently, search on stackoverflow and not found the right answer. As I’ve found it, so share it here, hopes this helps.

For previous part, you could refers to

Release Compiled APK — But not allow to install!!

I compile using Android Studio, and make it releasable as below

signingConfigs {
debug {
storeFile file("mydebug.keystore")
}
release {
storeFile file("mykeystroke-file")
storePassword "myFilePassword"
keyAlias "myAlias"
keyPassword "myAliasPassword:)"
}
}

buildTypes {
debug {
minifyEnabled false
signingConfig signingConfigs.debug
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile(
'proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}

Everything is good and it could easily get installed and run.

However, when I think of installing using ADB command as below

adb install myapplication.apk

It complaint can’t be install, with the below message

Failure [INSTALL_FAILED_TEST_ONLY]

Why??

It is not a debug build. It is properly signed. But it is not able to get install using ADB. I could install using Android Studio. So why?

I search on stackoverflow, various solution posted.

One stating the gradle might be a beta version. But I’m using gradle 3.0.0, a stable version.

The other state I could use -t option to install i.e.

adb install -t myapplication.apk

This would work. But why?? This is not a test APK, but a real releasable compiled and signed APK.

My findings

After thinking for a while, I remember my previous post

There’s a different between manually compile using Android Studio UI compile, vs an actual compile for release i.e. using

./gradlew app:assembleRelease

The Android Studio UI Compile is only for testing purposes and fit on certain devices. For actual production, we should use the above ./gradlew above.

By using ./gradlew compile, the APK now could be installed using

adb install myapplication.apk

I should have know this earlier, but this surprise me a while, since most of the real release is done through CI, and forgotten about it. Hopes this info is useful for you.

If you want to get future updates from me, do follow me on medium, Twitter or Facebook.