Android应用程序打开和关闭-React Native Signed App

时间:2017-12-29 05:33:43

标签: android reactjs react-native signed-apk

我已经在Android设备上安装了已签名的APK。安装后,它会在一秒内崩溃/关闭。

我已按照官方反应原生文档采取签名发布APK。 React Native Documentation

我附上了我的build.gradle

    def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 23
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.samplemobileapp"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            // minifyEnabled enableProguardInReleaseBuilds
            // proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    // buildTypes {
    //     release {
    //         minifyEnabled enableProguardInReleaseBuilds
    //         proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    //     }
    // }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

请告诉我这个框架问题或代码问题。

1 个答案:

答案 0 :(得分:0)

您需要在gradle.properties文件中设置密钥库文件属性。

你可以在android / gradle.properties

下找到这个文件
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=MYPASS
MYAPP_RELEASE_KEY_PASSWORD=MYPASS