简体   繁体   English

Android Studio Release版本给了我:不幸的是,“App Name”已停止

[英]Android Studio Release build gives me: Unfortunately, “App Name” has stopped

I'm working on Android Studio 1.1.0. 我正在使用Android Studio 1.1.0。 The build variant debug works perfectly but when I tried to run the release build variant the app starts but gives me an "Unfortunately, “App Name” has stopped." 构建变体debug工作得很好,但是当我尝试运行release构建变体时,应用程序启动,但给了我一个“不幸的”,应用程序名称“已停止”。

I already signed my apps in the past, maybe I'm missing a simple step which I completely forgot, what have I missed? 我过去已经签署了我的应用程序,也许我错过了一个我完全忘记的简单步骤,我错过了什么?

This is my build.gradle : 这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "com.madx.quiz.apf"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }

    signingConfigs {
        release {
            storeFile file('/Users/madx/Documents/Workspaces/Android/APF/app/keystore.keystore')
            storePassword ‘my_store_password’
            keyAlias ‘my_key_alias’
            keyPassword ‘my_key_password’
        }
        debug {}
    }

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

repositories{
// some repositories
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v13:21.0.0'
    compile 'com.google.code.gson:gson:2.3.1'
}

Event log gives me: 事件日志给了我:

19:52:49 Gradle build finished in 3 sec
19:52:50 Session 'app': running

Logcat: logcat的:

03-02 19:33:11.851  25913-25913/com.madx.quiz.apf I/art﹕ Late-enabling -Xcheck:jni
03-02 19:33:12.840  25913-25946/com.madx.quiz.apf D/OpenGLRenderer﹕ Render dirty regions requested: true
03-02 19:33:12.849  25913-25913/com.madx.quiz.apf D/Atlas﹕ Validating map...
03-02 19:33:12.922  25913-25946/com.madx.quiz.apf I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: QUALCOMM Build: 10/24/14, 167c270, I68fa98814b
03-02 19:33:12.924  25913-25946/com.madx.quiz.apf I/OpenGLRenderer﹕ Initialized EGL, version 1.4
03-02 19:33:12.936  25913-25946/com.madx.quiz.apf D/OpenGLRenderer﹕ Enabling debug mode 0

Gradle console: Gradle控制台:

Executing tasks: [:app:generateReleaseSources]

Configuration on demand is an incubating feature.
:app:preBuild
:app:preReleaseBuild
:app:checkReleaseManifest
:app:preDebugBuild
:app:prepareComAfollestadMaterialDialogs0612Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72103Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV132100Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42103Library UP-TO-DATE
:app:prepareComGithubDanielemaddalunoAndroidupdatecheckerLibrary102Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources
:app:generateReleaseSources

BUILD SUCCESSFUL

Total time: 2.4 secs

Try disabling ProGuard in your release build: 尝试在发布版本中禁用ProGuard:

build.gradle : build.gradle

buildTypes {
    release {
        signingConfig signingConfigs.release
        zipAlignEnabled true
    }
    debug {
    }
}

The problem is probably caused by ProGuard, but without the stacktrace, I can't really fix your problem. 问题可能是由ProGuard引起的,但如果没有堆栈跟踪,我无法解决您的问题。

I you still want to use proguard I suggest you to look for more information about the error, you can add in the release field the following: 我仍然想使用proguard我建议您查找有关错误的更多信息,您可以在发布字段中添加以下内容:

debuggable true
jniDebuggable true

So you can better identify the problem. 所以你可以更好地识别问题。 However probably the problem is linked to gson library, you should add to the proguard-rules.pro file the following lines (you could check a more complex example here ): 但是可能问题与gson库有关,你应该在proguard-rules.pro文件中添加以下行(你可以在这里查看一个更复杂的例子):

# Add any classes the interact with gson
-keepclassmembers class com.madx.quiz.apf.apf.APFQuestion { *; }
-keepclassmembers class com.madx.quiz.apf.apf.APFSubCategory { *; }

###---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

##---------------End: proguard configuration for Gson  ----------

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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