3

App is installing while connecting via USB to mobile, but while sending .apk file to others it saying "App not Installed"(both debug and release).I have tried different solutions from stackoverflow but none worked for me.

1.How to overcome app not installed error when building from Android Studio 3.0?

2.Cannot install signed apk to device manually, got error "App not installed"

3.Android Studio 3.0 Unsigned Apk Not Installing

Below is my build.gradle(app level)

android {
    compileSdkVersion 'android-P'
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "XXXXXXX"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 51
        versionName "1.51"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }

    }
    lintOptions{
        disable 'MissingTranslation'
    }

}

Please help me on this.Thanks in Advance.

Vidhi Dave
  • 5,614
  • 2
  • 33
  • 55
Naveen
  • 481
  • 2
  • 6
  • 23
  • 1
    increase your `targetSdkVersion 26` to `targetSdkVersion 27` or whatever for `android P` – KuLdip PaTel Mar 12 '18 at 11:17
  • Remove `buildToolsVersion '26.0.2'` line. – azizbekian Mar 12 '18 at 11:18
  • Check this thing where you are installing that .apk file :- Settings -> Security -> Unknown Source should be checked . If it's checked then clean and rebuild the project then build apk – Abhinav Gupta Mar 12 '18 at 11:20
  • hi Kuldip, Aziibekian, Abhinav I have tried above solutions specified unfortunetely none worked me.Thanks for your response guys.Please help me on this. – Naveen Mar 12 '18 at 11:39

2 Answers2

6

You can override testOnly flag adding following line to gradle.properties:

android.injected.testOnly=false
mol
  • 2,607
  • 4
  • 21
  • 40
4

Android P preview SDK is a preview and you should not be distributing APKs built with it. Use a non-preview SDK for compiling APKs that are meant for other people to use.

Technically, the installation limitation is that the APKs have testOnly flag set to true. To work around that, see ADB Install Fails With INSTALL_FAILED_TEST_ONLY

laalto
  • 150,114
  • 66
  • 286
  • 303
  • Hi laalto, Thanks for your response. I need to build both debug and release builds.will both(debug and release) builds will work if I add android:testOnly="true" in Manifest file ?Can you please help me on this. – Naveen Mar 12 '18 at 11:44
  • I don't think you can override the testonly flag set by P preview SDK. Just don't use a preview SDK that widely yet. – laalto Mar 12 '18 at 11:51
  • Hi, when I degrade compileSdkVersion 26, Project not building showing cornerRadiusError in values.xml.I cannot able to understand.Please help me on this. – Naveen Mar 12 '18 at 11:57
  • Error:(9, 5) error: resource android:attr/dialogCornerRadius not found. when I degrade to compileSdkVersion 26 – Naveen Mar 12 '18 at 12:06
  • Guess: you have `+` dynamic dependencies to support libraries and are getting too new a version. Hardcode your dependency versions. – laalto Mar 12 '18 at 12:08
  • I didn't get you laalto.Sorry can you please explain ? – Naveen Mar 12 '18 at 12:11
  • Post a new question with that particular issue. Include your build.gradle `dependencies` – laalto Mar 12 '18 at 12:20
  • Hi laalto, Can you please check the link, https://stackoverflow.com/questions/49249713/cannot-able-to-build-the-project-after-upgrading-to-android-p.Please help me on this. – Naveen Mar 13 '18 at 06:48
  • Added Dependencies to this Link, https://stackoverflow.com/questions/49249713/cannot-able-to-build-the-project-after-upgrading-to-android-p – Naveen Mar 13 '18 at 07:11