0

在这种情况下,我想为权限(FINE_LOCATION)添加/修改 AndroidManifest.xml,所以我查看了它在 Shoutem firebase 扩展(https://github.com/shoutem/extensions/tree/master/shoutem-火力基地)。

在预览应用程序中,这不是必需的,该应用程序已经获得了位置(以及更多)权限,但我认为如果我想将它提交到 Play 商店/手动安装它,应该将它添加到我的自定义扩展中Android 设备(如果我猜错了请纠正我)。

问题

我是否完成了使用 Shoutem 平台修改 AndroidManifest.xml 的正确步骤?

结果

使用 Shoutem CLI 构建成功,但 CLI 在复制到构建文件夹时挂起,在 Android 设备上安装失败

我做了以下事情: - 在 /app 中创建了一个 AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.shoutemapp">
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <application>
    </application>
</manifest>

更新了 app/package.json,添加了:

,
"rnpm": {
    "commands": {
        "postlink": "node node_modules/[myusername].[extensionname]/scripts/run.js"
    }
}

/scripts/run.js 的内容:

require('./android/copy_custom_manifest');

/android/copy_custom_manifest 的内容:

与 firebase 扩展相同,我的 username.extensionname 在 extensionPath 中:

/* eslint-disable max-len*/
 'use_strict';

const fs = require('fs');
const MANIFEST_FILE = 'AndroidManifest.xml';

const extensionPath = './node_modules/[myusername].[extensionname]';
const manifestFilePath = `${extensionPath}/${MANIFEST_FILE}`;
const customManifestFileDestination = `android/app/src/customized/${MANIFEST_FILE}`;

const readStream = fs.createReadStream(manifestFilePath);
const writeStream = fs.createWriteStream(customManifestFileDestination, { flags: 'a' });
readStream.on('error', console.log.bind(null, `Unable to read from ${manifestFilePath}`));
writeStream.on('error', console.log.bind(null, `Unable to write to ${customManifestFileDestination}`));
writeStream.on('finish', console.log.bind(null, `copied ${manifestFilePath} to ${customManifestFileDestination}`));

fs.truncate(customManifestFileDestination, 0, (err) => {
  if (err) {
    process.exitCode = 1;
    throw new Error(`Unable to overwrite, ${manifestFilePath} does not exist`);
  }

  console.log(`Overwrite ${customManifestFileDestination} with ${manifestFilePath}`);
  readStream.pipe(writeStream);
});

我在构建过程中没有遇到错误,但应用程序不会安装在物理设备上,使用:

shoutem build-android

控制台输出:

BUILD SUCCESSFUL
Total time: 2 mins 43.478 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.10/userguide/gradle_daemon.html
Copying .apk to /Users/matthijs/Documents/shoutem/builds
--> It stops on this last line (copying .apk), no error.
There was one error however:
[5/3/2017, 12:06:07 PM] <START> Initializing Packager
[5/3/2017, 12:06:07 PM] <START> Building in-memory fs for JavaScript
[5/3/2017, 12:06:07 PM] <END> Building in-memory fs for JavaScript (108ms)
[5/3/2017, 12:06:07 PM] <START> Building Haste Map
[5/3/2017, 12:06:07 PM] <END> Building Haste Map (304ms)
[5/3/2017, 12:06:07 PM] <END> Initializing Packager (473ms)
platform.buildPlatform(...).finally is not a function
If you think this error is caused by bug in the shoutem command, you can report the issue here: https://github.com/shoutem/cli/issues
Make sure to include the information printed using the `shoutem last-error` command
> @shoutem/mobile-app@0.56.0 build /private/var/folders/xp/strzbzt15zz4k1pvmgc99rj40000gn/T/tmp-8209NeOBTGdT1e1B
> node scripts/build "--platform" "android" "--outputDirectory" "/Users/matthijs/Documents/shoutem/builds"
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preCustomizedReleaseBuild UP-TO-DATE
4

1 回答 1

0

这是@shoutem/cli 的问题。现在已经发布了一个较新的版本 (v0.8.143),它解决了这个问题。更新您的@shoutem/cli,您的构建应该没有错误。

CLI 应该会在您下次使用时提示您更新它,因此只需使用

$ shoutem -v

将提示您使用是/否更新选项。

如果您拒绝更新,则不会再次提示您,但会收到警告:

“警告:这是一个过时版本的shoutem CLI”

您可以使用以下命令安装最新版本:

$ npm install -g @shoutem/cli
于 2017-05-03T15:19:18.677 回答