简体   繁体   中英

“App not installed” on device error from debug apk, “File appears to be corrupt”

I am attempting to generate an apk to install to a device. I was able to do this with the same project prior to Android Studio version 3.0.0. I cannot post any error logs because the apk generates successfully, but when I try to install it on a device I get "App not installed", "File appears to be corrupt". I have been through a number of other threads to try and fix this but nothing has worked so far.

The previous version on the phone has been uninstalled. Both Signed and unsigned have been tried. Instant run has been disabled. The apk has failed to install on at least 3 different devices. I have tried downgrading my com.android.tools.build:gradle

Any help would be greatly appreciated, I feel like I've tried everything.

build.gradle (app):

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
    applicationId "com.example.will3596.mobileapplication"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}

dependencies {
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:11.6.2'
compile 'com.google.firebase:firebase-auth:11.6.2'
compile 'com.google.firebase:firebase-database:11.6.2'
compile 'com.google.android.gms:play-services-maps:11.6.2'
compile 'com.google.android.gms:play-services-location:11.6.2'
compile 'com.google.firebase:firebase-storage:11.6.2'
compile 'com.android.support:palette-v7:26.+'
compile 'com.android.support:customtabs:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:mediarouter-v7:26.+'
compile 'com.android.support:multidex:1.0.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.maps.android:android-maps-utils:0.4+'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.7.22'
androidTestCompile 'com.android.support:support-annotations:24.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
}
apply plugin: 'com.google.gms.google-services'

build.gradle (project):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

 buildscript {
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.1'
    classpath 'com.google.gms:google-services:3.1.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
    maven{
        url "https://maven.google.com"
    }
    google()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

Let me know what else I can post to help get a solution.

Steps to generate debug apk from 3.0.0+

Build->Build APK(s).

I found the answer in another thread somewhere. In my android manifest, I had testOnly="true", set to false and it fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM