在本例中,我想添加/修改AndroidManifest.xml,用于权限(FINE_LOCATION),因此我查看了在Shoutem扩展(https://github.com/shoutem/extensions/tree/master/shoutem-firebase)中是如何做到的。
在预览应用程序中,这是不需要的,该应用程序已经获得了定位权限(等等),但是如果我想将它提交到Play Store /在我的Android设备上手动安装它(如果我假设错误的话,请纠正我的错误),我假设应该将它添加到我的自定义扩展中。
问题
我是否完成了使用Shoutem平台修改AndroidManifest.xml的正确步骤?
结果
使用Shoutem CLI成功构建,但是CLI挂起复制到builds文件夹,Android设备上的安装失败。
我做了以下工作:-在/app中创建了一个/app:
<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"
}
}/script/run.js的内容:
require('./android/copy_custom_manifest');/android/copy_定制_清单的内容:
与firebase扩展相同,在extensionPath中使用我的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发布于 2017-05-03 15:19:18
这是@shoutem/cli的一个问题。现在已经发布了一个较新的版本(v0.8.143),它解决了这个问题。更新您的@shoutem/cli,您的构建应该是无错误的。
CLI应该提示您下次使用它时更新它,所以只需使用
$ shoutem -v将提示您使用“是”/“否”更新选项。
如果您拒绝更新,您将不会再次被提示,但您将被警告:
警告:这是一种过时的shoutem CLI版本
您可以通过以下方式安装最新版本:
$ npm install -g @shoutem/clihttps://stackoverflow.com/questions/43761631
复制相似问题