应用程序作为 APK 运行,但通过 Play 商店发布时崩溃

Posted

技术标签:

【中文标题】应用程序作为 APK 运行,但通过 Play 商店发布时崩溃【英文标题】:App working as an APK but when released through play store it crashes 【发布时间】:2021-06-17 07:28:57 【问题描述】:

我知道很多次这是 proguard 的问题,我对此不是很熟悉我已经发布了我的 build gradle 和 proguard 我希望有人可以帮助我,因为我也没有收到任何崩溃报告,所以我感觉有点黑暗的。 build.gradle

apply plugin: 'com.android.application'
apply plugin: "androidx.navigation.safeargs"

android 

    def versionMajor = 1
    def versionMinor = 1
    def versionPatch = 26

    compileSdkVersion 29

    defaultConfig 
        applicationId "com.my.app"
        minSdkVersion 24
        targetSdkVersion 29
        versionCode versionMajor * 1000 + versionMinor * 100 + versionPatch
        versionName "$versionMajor.$versionMinor.$versionPatch"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        ndk 
            abiFilters "armeabi-v7a", "arm64-v8a"
        
        compileOptions 
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
            javaCompileOptions 
                annotationProcessorOptions 
                    arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
                
            

        

    
    buildTypes 
        debug
            resValue "string", "app_version", "$defaultConfig.versionName"
        
        release 
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            resValue "string", "google_maps_key", "Release_API_KEY"
            resValue "string", "app_version", "$defaultConfig.versionName"
        
    
    dataBinding 
        //enabled = true;
    
    packagingOptions 
        exclude 'META-INF/DEPENDENCIES'
    


repositories 
    mavenCentral()


repositories 
    maven  url "https://www.jitpack.io" 
    jcenter()



dependencies 
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'androidx.preference:preference:1.1.0'
    implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.android.support:support-v4:29.0.0'
    implementation 'com.android.support:preference-v7:29.1.0'
    implementation 'com.android.support:appcompat-v7:29.1.0'
    implementation 'com.android.support:design:29.1.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:17.6.0'
    implementation 'com.karumi:dexter:6.0.2'
    implementation 'com.jakewharton:butterknife:10.2.1'
    implementation files('libs/opencsv-2.4.jar')
    implementation files('libs/jdxf.jar')
    implementation files('libs/jna-5.5.0.jar')
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
    implementation 'androidx.wear:wear:1.0.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
    implementation "com.squareup.okhttp3:okhttp:4.4.0"
    // implementation files('libs/opencsv-2.1-1.0.0.jar')
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation "io.reactivex.rxjava3:rxjava:3.0.1"
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
    implementation "com.squareup.okhttp3:okhttp:3.3.0"
    implementation 'com.squareup.retrofit2:retrofit:2.7.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.2'
    implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
    implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    implementation 'org.jgrapht:jgrapht-io:1.4.0'
    // https://mvnrepository.com/artifact/org.apache.tinkerpop/tinkerpop
    implementation group: 'org.apache.tinkerpop', name: 'tinkerpop', version: '3.4.6', ext: 'pom'
    // https://mvnrepository.com/artifact/org.apache.tinkerpop/tinkergraph-gremlin
    annotationProcessor group: 'org.apache.tinkerpop', name: 'tinkergraph-gremlin', version: '3.4.6'
    implementation group: 'org.apache.tinkerpop', name: 'tinkergraph-gremlin', version: '3.4.6'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation group: 'commons-io', name: 'commons-io', version: '2.6'


    implementation 'com.google.android.material:material:1.1.0'
    compileOnly 'com.google.android.wearable:wearable:2.6.0'

    def nav_version = "2.3.1"

    // Java language implementation
    implementation "androidx.navigation:navigation-fragment:$nav_version"
    implementation "androidx.navigation:navigation-ui:$nav_version"

    // Dynamic Feature Module Support
    implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
    // Testing Navigation
    androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"

    // Jetpack Compose Integration
    implementation "androidx.navigation:navigation-compose:1.0.0-alpha01"
    implementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    def room_version = "2.2.4"

    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    // For Kotlin use kapt instead of annotationProcessor

    // optional - Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:$room_version"

    // optional - RxJava support for Room
    implementation "androidx.room:room-rxjava2:$room_version"

    // optional - Guava support for Room, including Optional and ListenableFuture
    implementation "androidx.room:room-guava:$room_version"

    // Test helpers
    testImplementation "androidx.room:room-testing:$room_version"

    implementation 'androidx.multidex:multidex:2.0.1'
    // https://mvnrepository.com/artifact/javax.xml.stream/stax-api
    implementation group: 'javax.xml.stream', name: 'stax-api', version: '1.0-2'
// https://mvnrepository.com/artifact/com.fasterxml/aalto-xml
    implementation group: 'com.fasterxml', name: 'aalto-xml', version: '1.2.2'

    //Email
    implementation 'com.sun.mail:android-mail:1.6.4'
    implementation 'com.sun.mail:android-activation:1.6.4'

    //okhttp
    implementation 'com.squareup.okhttp3:okhttp:3.14.6'

    //Json
    implementation 'com.android.volley:volley:1.1.0'

    //seekarc
    implementation 'com.github.Triggertrap:SeekArc:v1.1'

    implementation 'com.github.tbruyelle:rxpermissions:0.10.2'
    implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
    // For developers using AndroidX in their applications
    implementation 'pub.devrel:easypermissions:3.0.0'
    implementation 'org.altbeacon:android-beacon-library:2+'


proguard-rules(为空)

# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the javascript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview 
#   public *;
#

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

如果有任何方法可以让我获得调试报告或了解问题,那将有很大帮助。

【问题讨论】:

【参考方案1】:

崩溃日志可在您应用的 Google Play 控制台中的“质量”/“Android Vitals”/“崩溃和 ANR”部分中找到。它将列出崩溃并包含每个崩溃的堆栈跟踪。不幸的是,如果代码被 proguard 混淆,堆栈跟踪可能不会提供完整的类/方法名称,直到你 upload the mapping.txt file

【讨论】:

以上是关于应用程序作为 APK 运行,但通过 Play 商店发布时崩溃的主要内容,如果未能解决你的问题,请参考以下文章

在 Play 商店外分发 apk(到非 gms 设备)

无法在Play商店上传apk

如何从 Jenkins/Hudson 上传 APK 到 Play 商店?

如何在Play商店上传拆分应用程序二进制文件

了解 APK、ABB 大小和 Play 商店大小限制

APK 版本未从 Play 商店更新已安装的 AAB 应用