在React Native中从Windows生成APK

时间:2017-09-19 03:25:50

标签: reactjs react-native

我想从Windows生成签名APK以在真实手机中进行测试。我已经完成了应用程序的开发,但是当我编译并尝试在我的Android手机中安装时,它说"无法安装此应用程序"。

我有点困惑:https://facebook.github.io/react-native/docs/signed-apk-android.html

我找不到〜/ .gradle / gradle.properties

我的android / app / build.gradle没有像这里的android字:

android {
...
defaultConfig { ... }
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
    }
}

}

任何人都可以帮助我

编辑1:我的build.gradle

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

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'

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

allprojects {
repositories {
    mavenLocal()
    jcenter()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
}
   }

1 个答案:

答案 0 :(得分:0)

档案 - >机器人/ gradle.properties

  

MYAPP_RELEASE_STORE_FILE =我的离型key.keystore   MYAPP_RELEASE_KEY_ALIAS =我的钥匙别名   MYAPP_RELEASE_STORE_PASSWORD = SAMPLE MYAPP_RELEASE_KEY_PASSWORD = SAMPLE   android.useDeprecatedNdk =真

档案 - >机器人/应用/的build.gradle

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
    }
}

将my-release-key.keystore文件放在项目文件夹中的android / app目录下。