通过Shoutem平台修改AndroidManifest.xml
Modify AndroidManifest.xml through Shoutem platform
在这种情况下,我想 add/modify AndroidManifest.xml 获得权限 (FINE_LOCATION),所以我查看了 Shoutem firebase 扩展中的操作方式 (https://github.com/shoutem/extensions/tree/master/shoutem-firebase ).
在预览版应用程序中,这不是必需的,该应用程序已经获得了位置(以及更多)权限,但我认为如果我想将其提交到 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
这是@shoutem/cli 的问题。现已发布更新版本 (v0.8.143),解决了该问题。更新您的@shoutem/cli,您的构建应该没有错误。
CLI 应该会提示您在下次使用时更新它,所以只需使用
$ shoutem -v
将提示您 Yes/No 更新选项。
如果您拒绝更新,您将不会再次收到提示,但会收到警告:
"Warning: This is an outdated version of shoutem CLI"
您可以安装最新版本:
$ npm install -g @shoutem/cli
在这种情况下,我想 add/modify AndroidManifest.xml 获得权限 (FINE_LOCATION),所以我查看了 Shoutem firebase 扩展中的操作方式 (https://github.com/shoutem/extensions/tree/master/shoutem-firebase ).
在预览版应用程序中,这不是必需的,该应用程序已经获得了位置(以及更多)权限,但我认为如果我想将其提交到 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
这是@shoutem/cli 的问题。现已发布更新版本 (v0.8.143),解决了该问题。更新您的@shoutem/cli,您的构建应该没有错误。
CLI 应该会提示您在下次使用时更新它,所以只需使用
$ shoutem -v
将提示您 Yes/No 更新选项。
如果您拒绝更新,您将不会再次收到提示,但会收到警告:
"Warning: This is an outdated version of shoutem CLI"
您可以安装最新版本:
$ npm install -g @shoutem/cli