如何使用Cordova将SAP Fiori应用打包并安装到Android平台上

简介: 如何使用Cordova将SAP Fiori应用打包并安装到Android平台上

There is a wonderful tutorial Building SAP Fiori-like UIs with SAPUI5 in 10 Exercises written by Bertram Ganz.


In this blog, I will show step by step how to package the UI5 application built by this tutorial as a native application into your Android device.


Here below are some screenshot of this UI5 running in my mobile phone.image.pngimage.pngimage.pngimage.png(1) install nodejs in your laptop, and add the installation folder to your environment variable.image.png(2) Install Cordova via npm -g install cordova:image.png(3) Create a new folder. And then go into this folder, create a new Cordova project via the following command:image.pnghen a skeleton project with those files and folders are automatically created.image.pngPlatforms folder is empty so far since I don’t add any mobile platform yet.

(4) Add android platform support via command: cordova platform add androidimage.pngOnce done, the necessary artifacts (Android platform specific) for APK generation are created under folder platforms/android.image.pngNow you should have the folders with the following hierarchy:image.png(5) By default there is a dummy index.html file existing in folder www. Using command cordova prepare, the index.html will be copied automatically to folder platforms\android\assets\www. So the general idea here is we always develop the artifacts of our web application in www folder. Once done, use cordova prepare to synchronize it to android platform related folder.


Then use command cordova compile, and you will see the APK file generated successfully.image.pngYou might meet with the error message below during compile:


[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TGznex9F-1598619431139)(https://upload-images.jianshu.io/upload_images/2085791-16bcff409a2e7c77.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]


In this case just download the binary version of gradle, unzip it and configure the executable file path in your PATH environment variable:image.pngnstall the APK into your mobile device and you should see the following picture:image.png(6) I have uploaded my test Fiori application to my github.

Download folder scn_exercise and index.html from folder www, and copy it to your folder www in your local project.image.pngimage.png7) Once done, execute cordova prepare and cordova compile once again, and the new APK will be created. Install it to your device to see final result.


Note: although the Fiori application itself can work offline with a mocked data model, in order to reduce the size of packaged APK file, I didn’t package UI5 library to the APK, but instead declare a reference to UI5 library with online version, which means when you test this application in your mobile phone, it is a must that your phone should have internet access.image.pngIf you don’t have an Android device, you can also test it in Emulator ( you have to install Android development studio first )

Create a new virtual device and launch it:image.pngThen use the following command to install the APK into emulator:image.pngNow you can test the application in emulator:image.pngimage.png






相关文章
|
4月前
|
JavaScript Android开发
Cordova 打包 Vue 项目到Android打开白屏
Cordova 打包 Vue 项目到Android打开白屏
|
JavaScript Android开发
Cordova 打包 Vue 项目到Android打开白屏
Cordova 打包 Vue 项目到Android打开白屏问题解决方案,更改 publicPath 属性值为 ./。
|
16天前
|
消息中间件 网络协议 Java
Android 开发中实现数据传递:广播和Handler
Android 开发中实现数据传递:广播和Handler
16 1
|
18天前
|
Linux 编译器 Android开发
FFmpeg开发笔记(九)Linux交叉编译Android的x265库
在Linux环境下,本文指导如何交叉编译x265的so库以适应Android。首先,需安装cmake和下载android-ndk-r21e。接着,下载x265源码,修改crosscompile.cmake的编译器设置。配置x265源码,使用指定的NDK路径,并在配置界面修改相关选项。随后,修改编译规则,编译并安装x265,调整pc描述文件并更新PKG_CONFIG_PATH。最后,修改FFmpeg配置脚本启用x265支持,编译安装FFmpeg,将生成的so文件导入Android工程,调整gradle配置以确保顺利运行。
FFmpeg开发笔记(九)Linux交叉编译Android的x265库
|
19天前
|
Unix Linux Shell
FFmpeg开发笔记(八)Linux交叉编译Android的FFmpeg库
在Linux环境下交叉编译Android所需的FFmpeg so库,首先下载`android-ndk-r21e`,然后解压。接着,上传FFmpeg及相关库(如x264、freetype、lame)源码,修改相关sh文件,将`SYSTEM=windows-x86_64`改为`SYSTEM=linux-x86_64`并删除回车符。对x264的configure文件进行修改,然后编译x264。同样编译其他第三方库。设置环境变量`PKG_CONFIG_PATH`,最后在FFmpeg源码目录执行配置、编译和安装命令,生成的so文件复制到App工程指定目录。
FFmpeg开发笔记(八)Linux交叉编译Android的FFmpeg库
|
6天前
|
存储 安全 Android开发
安卓应用开发:构建一个高效的用户登录系统
【5月更文挑战第3天】在移动应用开发中,用户登录系统的设计与实现是至关重要的一环。对于安卓平台而言,一个高效、安全且用户体验友好的登录系统能够显著提升应用的用户留存率和市场竞争力。本文将探讨在安卓平台上实现用户登录系统的最佳实践,包括对最新身份验证技术的应用、安全性考量以及性能优化策略。
|
9天前
|
前端开发 Android开发 iOS开发
【Flutter前端技术开发专栏】Flutter在Android与iOS上的性能对比
【4月更文挑战第30天】Flutter 框架实现跨平台移动应用,通过一致的 UI 渲染(Skia 引擎)、热重载功能和响应式框架提高开发效率和用户体验。然而,Android 和 iOS 的系统差异、渲染机制及编译过程影响性能。性能对比显示,iOS 可能因硬件优化提供更流畅体验,而 Android 更具灵活性和广泛硬件支持。开发者可采用代码、资源优化和特定平台优化策略,利用性能分析工具提升应用性能。
【Flutter前端技术开发专栏】Flutter在Android与iOS上的性能对比
|
10天前
|
监控 Java Android开发
安卓应用开发:打造高效用户界面的五大策略
【4月更文挑战第29天】 在安卓应用开发的世界中,构建一个既美观又高效的用户界面(UI)对于吸引和保留用户至关重要。本文将深入探讨五种策略,这些策略可以帮助开发者优化安卓应用的UI性能。我们将从布局优化讲起,逐步过渡到绘制优化、内存管理、异步处理以及最终的用户交互细节调整。通过这些实践技巧,你将能够为用户提供流畅而直观的体验,确保你的应用在竞争激烈的市场中脱颖而出。
|
1天前
|
Java API 开发工具
java与Android开发入门指南
java与Android开发入门指南
6 0
|
2天前
|
Android开发 Kotlin
Kotlin开发Android之基础问题记录
Kotlin开发Android之基础问题记录
13 1