Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
473 views
in Technique[技术] by (71.8m points)

android - My newly released app can't be installed: Error code: -504

I just released my app to the Google Play Store, and the signed apk was published successfully. However, (and I've tried this on three different phones and tablets), the app refuses to install when downloaded from the store. After clicking the "Install" button, the app will download, the status will change to "Installing..." and then the following dialog appears:

Can't be installed: Error code: -504

What can be done?

Facts about my app that could help troubleshooting:

  • The app is targeting API22 with a minSDK of 17.
  • I'm not using proguard.
  • The app is using multidex via the multidex support library.

app/build.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    jcenter()
}

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "io.givenow.app"
        minSdkVersion 17
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"

        // Enabling multidex support.
        multiDexEnabled true
    }

    signingConfigs {
        debug {
            storeFile file('../debug.keystore')
        }
        release
    }

    productFlavors {
        // Define separate dev and prod product flavors.
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 17
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion 17
        }
    }

    buildTypes {
        debug {
            minifyEnabled false
        }

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

apply from: 'https://raw.github.com/trikita/gradle-android-signing/master/gradle-android-signing.gradle'


dependencies {
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.guava:guava:18.0'
    compile 'org.functionaljava:functionaljava:4.4'
    compile 'io.reactivex:rxandroid:1.0.1'
    // Because RxAndroid releases are few and far between, it is recommended you also
    // explicitly depend on RxJava's latest version for bug fixes and new features.
    compile 'io.reactivex:rxjava:1.0.14'

    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:support-v13:23.1.1'
    compile 'com.google.android.gms:play-services-maps:8.3.0'
    compile 'com.google.android.gms:play-services-location:8.3.0'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:palette-v7:23.1.1'

    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.google.maps.android:android-maps-utils:0.4'
    compile 'com.github.chrisbanes.actionbarpulltorefresh:library:0.9.9'
    compile 'com.nhaarman.listviewanimations:library:2.6.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    //    compile 'jp.wasabeef:recyclerview-animators:2.0.1'
    compile 'com.bartoszlipinski:viewpropertyobjectanimator:1.1.0'
    //    compile 'com.androidmapsextensions:android-maps-extensions:2.1.0+'

    compile 'com.parse.bolts:bolts-android:1.2.1'
    compile 'com.parse:parse-android:1.10.3'
    compile 'com.parse:parseui-login-android:0.0.1'
    compile 'com.parse:parseui-widget-android:0.0.1'
    // Uncomment if using Facebook Login (optional Maven dependency)
    //    compile 'com.facebook.android:facebook-android-sdk:4.6.0'
    //    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    //    compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
    compile('de.keyboardsurfer.android.widget:crouton:1.8.4@aar') { //maybe drop the @aar later
        // exclusion is not neccessary, but generally a good idea.
        exclude group: 'com.google.android', module: 'support-v4'
    }
    //    compile project(':stripe')
    //    compile 'io.card:android-sdk:5.0.1'
    //    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    // fork of Pager Sliding Tab Strip that supports ColorStateLists for tab text color.
    // https://github.com/magicgoose/PagerSlidingTabStrip
    compile project(':PagerSlidingTabStrip-magicgoose-1c26523:library')
    //    compile project(':recyclerview-animators')
    compile project(':animators')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.3@aar') {
        transitive = true;
    }
}

Top-level build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
    }
}

plugins {
    id "me.tatarka.retrolambda" version "3.2.3"
}

allprojects {
    repositories {
        mavenCentral()
    }
}

Note: This is very hard to google for because most answers deal with the client-side, i.e. users getting this error when trying to download apps.


Update 1+2:

Installing the signed apk manually with adb install produces Failure [INSTALL_FAILED_DEXOPT] and the following logcat stack trace.

It should be noted that running the debug version of the app (with a minSdkVersion of 21) on my phone via android studio works flawlessly.

This could be related to multidex. When I change my minSdkVersion to 21, the app installs fine. But if I change it to 17, it fails. Here's an expanded version of the above stacktrace:

11-19 15:50:58.474 19186-19186/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
11-19 15:50:58.477 19186-19186/? D/AndroidRuntime: CheckJNI is OFF
11-19 15:50:58.642 19186-19186/? D/AndroidRuntime: Calling main entry com.android.commands.pm.Pm
11-19 15:50:58.706 3907-3907/? D/Finsky: [1] PackageVerificationReceiver.onReceive: Verification requested, id = 37
11-19 15:50:58.713 3907-3907/? D/Finsky: [1] WorkerTask.onPreExecute: Verification Requested for id = 37, data=file:///data/local/tmp/io.givenow.app flags=114 fromVerificationActivity=false
11-19 15:50:59.860 3907-3934/? I/qtaguid: Failed write_ctrl(u 44) res=-1 errno=22
11-19 15:50:59.860 3907-3934/? I/qtaguid: Untagging socket 44 failed errno=-22
11-19 15:50:59.860 3907-3934/? W/NetworkManagementSocketTagger: untagSocket(44) failed with errno -22
11-19 15:50:59.863 3907-3907/? D/Finsky: [1] 2.onResponse: Verification id=37 response=0
11-19 15:50:59.877 3907-3907/? D/Finsky: [1] PackageVerificationReceiver.onReceive: Verification requested, id = 37
11-19 15:50:59.890 19017-19033/? D/DefContainer: Copying /data/local/tmp/io.givenow.app to base.apk
11-19 15:51:00.633 809-869/? D/PackageManager: Renaming /data/app/vmdl171337004.tmp to /data/app/io.givenow.app-1
11-19 15:51:00.660 809-869/? I/PackageManager: Running dexopt on: /data/app/io.givenow.app-1/base.apk pkg=io.givenow.app isa=arm vmSafeMode=false
11-19 15:51:00.711 19203-19203/? I/dex2oat: /system/bin/dex2oat --zip-fd=6 --zip-location=/data/app/io.givenow.app-1/base.apk --oat-fd=7 --oat-location=/data/dalvik-cache/arm/data@[email protected]@[email protected] --instruction-set=arm --instruction-set-features=div --runtime-arg -Xms64m --runtime-arg -Xmx512m --swap-fd=24
11-19 15:51:01.187 19203-19203/? I/dex2oat: Decided to run without swap.
11-19 15:51:01.560 19203-19206/? W/dex2oat: Before Android 4.1, method int android.support.v7.internal.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
11-19 15:51:06.063 19203-19207/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xd94e27a4 in tid 19207 (Compiler driver)
11-19 15:51:06.066 19203-19203/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xd94e27a4 in tid 19203 (main)
11-19 15:51:06.102 19203-19205/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xd94e27a4 in tid 19205 (Compiler driver)
11-19 15:51:06.166 351-351/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-19 15:51:06.166 351-351/? I/DEBUG: Build fingerprint: 'google/shamu/shamu:5.1.1/LMY47Z/1860966:user/release-keys'
11-19 15:51:06.166 351-351/? I/DEBUG: Revision: '33696'
11-19 15:51:06.167 351-351/? I/DEBUG: ABI: 'arm'
11-19 15:51:06.167 351-351/? I/DEBUG: pid: 19203, tid: 19207, name: Compiler driver  >>> /system/bin/dex2oat <<<
11-19 15:51:06.167 351-351/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xd94e27a4
11-19 15:51:06.168 809-1027/? W/NativeCrashListener: Couldn't find ProcessRecord for pid 19203
11-19 15:51:06.193 351-351/? I/DEBUG:     r0 b163600c  r1 13f513f4  r2 b15af000  r3 0008700c
11-19 15:51:06.193 351-351/? E/DEBUG: AM write failure (32 / Broken pipe)
11-19 15:51:06.193 351-351/? I/DEBUG:     r4 000013f4  r5 d94d87f4  r6 73406b18  r7 d94d8807
11-19 15:51:06.193 351-351/? I/DEBUG:     r8 b6f70a70  r9 d94d8804  sl b6a46df4  fp 00000000
11-19 15:51:06.194 351-351/? I/DEBUG:     ip 00000000  sp b0dffb20  lr b6d47065  pc b6d46e26  cpsr 80070030
11-19 15:51:06.194 351-351/? I/DEBUG:     #00 pc 000dbe26  /system/lib/libart.so (art::ClassLinker::ResolveMethodExceptionHandlerTypes(art::DexFile const&, art::mirror::ArtMethod*)+81)
11-19 15:51:06.194 351-351/? I/DEBUG:     #01 pc 000dc061  /system/lib/libart.so (art::ClassLinker::ResolveClassExceptionHandlerTypes(art::DexFile const&, art::Handle<art::mirror::Class>)+108)
11-19 15:51:06.194 351-351/? I/DEBUG:     #02 pc 000dc28b  /system/lib/libart.so (art::ClassLinker::VerifyClass(art::Handle<art::mirror::Class>)+518)
11-19 15:51:06.194 351-351/? I/DEBUG:     #03 pc 00145be1  /system/lib/libart-compiler.so
11-19 15:51:06.194 351-351/? I/DEBUG:     #04 pc 0013f25d  /system/lib/libart-compiler.so
11-19 15:51:06.194 351-351/? I/DEBUG:     #05 pc 002438ed  /system/lib/libart.so (art::ThreadPoolWorker::Run()+44)
11-19 15:51:06.194 351-351/? I/DEBUG:     #06 pc 002441ed  /system/lib/libart.so (art::ThreadPoolWorker::Callback(void*)+60)
11-19 15:51:06.194 351-351/? I/DEBUG:     #07 pc 00016baf  /system/lib/libc.so (__pthread_start(void*)+30)
11-19 15:51:06.194 351-351/? I/DEBUG:     #08 pc 00014af3  /system/lib/libc.so (__start_thread+6)
11-19 15:51:06.403 809-850/? I/BootReceiver: Copying /data/tombstones/tombstone_03 to DropBox (SYSTEM_TOMBSTONE)
11-19 15:51:06.452 351-351/? E/DEBUG: unexpected waitpid response: n=19203, status=0000000b
11-19 15:51:06.452 351-351/? E/DEBUG: tid exited before attach completed: tid 19203
11-19 15:51:06.45

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I got it working!

Build tools version 23.0.2 is broken for multi-dexed apps.

Changing to buildToolsVersion "23.0.1" produces working, installable builds in both devDebug and prodRelease.

(As my post mentions, the former does not run proguard, the latter does, and both flavors target a minSdkVersion of 17).

This consumed two entire days. I hope this saves someone else's time, at least til 23.0.3 comes out!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...