生成签名APK时出错

时间:2015-11-18 16:51:03

标签: android react-native

我有一个React-Native Android应用程序,我正在尝试捆绑。我已经将主应用程序复制到'test'文件夹来执行此操作,并按照此处的说明进行操作:

Guide to Generate Signed APK

我正处于跑步的地步:

false

在我收到错误之前,似乎一切顺利。使用stacktrace运行给了我:

$ cd android && ./gradlew assembleRelease

建立失败

有没有人见过这个?任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:1)

对我有用的是,我删除了node_modules文件夹并执行了

npm install

cd android

./gradlew assembleRelease

答案 1 :(得分:0)

我没有遇到过这个问题,但是如果curl请求成功,那么听起来你的build.gradle在某种程度上是错误配置的。我使用“默认”反应原生项目提供的react.gradle文件。我的build.gradle配置看起来像粘贴在下面(注意:它使用了很多默认值,但我喜欢明确选项)。生成的packager命令如下所示:


    react-native bundle --platform android --dev true --entry-file react/index.android.js --bundle-output mobile/android/app/build/intermediates/assets/debug/index.android.bundle --assets dest mobile/android/app/build/intermediates/res/merged/debug

如果您的构建步骤进入此阶段并且崩溃,剩下的可能性是您的节点环境以某种方式错误配置。



    // React Native build configuration
    project.ext.react = [
            // the name of the generated asset file containing your JS bundle
            bundleAssetName    : "index.android.bundle",
            // the entry file for bundle generation
            entryFile          : "react/index.android.js",
            // whether to bundle JS and assets in debug mode

            // When building from Android Studio bundleInDebug evalutes to false while using gradlew
            // it overrides to true as it should. I don't 100% understand why that is, but luckily this
            // is the behavior I want to have.
            bundleInDebug      : true,
            // whether to bundle JS and assets in release mode
            bundleInRelease    : true,
            // the root of your project, i.e. where "package.json" lives
            root               : "../../",

            // were to put the JS bundle asset in debug mode
            jsBundleDirDebug   : "$buildDir/intermediates/assets/debug",
            // where to put the JS bundle asset in release mode
            jsBundleDirRelease : "$buildDir/intermediates/assets/release",

            // where to put drawable resources / React Native assets, e.g. the ones you use via
            // require('./image.png')), in debug mode
            resourcesDirDebug  : "$buildDir/intermediates/res/merged/debug",

            // were to put drawable resources / React Native assets, e.g. the ones you use via
            // require('./image.png')), in release mode
            resourcesDirRelease: "$buildDir/intermediates/res/merged/release",

            // b default the gradle tasks are skipped if none of the JS files or assets change; this means
            // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
            // date; if you have any other folders that you want to ignore for performance reasons (gradle
            // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
            // for example, you might want to remove it from here.
            inputExcludes      : []
    ]
    apply from: 'react.gradle'