将离子框架添加到现有 android 工作室应用程序

add ionic framework to an existing android studio app

我正在与 android studio 一起为 ODROID XU4 板开发一个项目。由于项目的性质,我正在使用 android studio 制作本机应用程序,以便使用开发板的一些硬件功能,如以太网、GPIO...,并且因为无意开发这适用于任何其他平台。

现在的问题是客户想要一个漂亮的离子界面。 我一直在测试我在 google、ionic 论坛、stack overflow 和许多其他网站中发现的大部分方法,但都没有成功。

我最接近的是创建一个离子应用程序,添加 android 平台并将其导入 android studio。

我的第一个问题是: 1- 这是正确的方法吗?

我的工作流程是:

ionic start myapp 
ionic platform add android
ionic build android

然后我用 android studio 导入 myapp 文件夹。 首先我得到一个 android 工作室错误:

 19:40:40 Migrate Project to Gradle?
         This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system.
         More Information about migrating to Gradle
         Don't show this message again.
19:40:41 Update Property Files
         The structure of following Android modules was changed:
         android
         CordovaLib
         Would you like to update related project.properties files?
         Only once
         Always for these modules
         Never for these modules
19:40:44 Update Property Files
         The structure of following Android modules was changed:
         android
         Would you like to update related project.properties files?
         Only once
         Always for these modules
         Never for these modules
19:40:45 IndexNotReadyException: Please change caller according to com.intellij.openapi.project.IndexNotReadyException documentation
19:48:09 Error Report: Submitted

现在是时候将项目迁移到 gradle:

这是主要问题,我不知道将新 gradle 文件放在哪里或如何继续。

谢谢。

首先:您的方向是正确的。这是正确的做法。但是,我认为您的问题是因为您将错误的文件夹导入 Android Studio。

请在您的 myApp/platforms 文件夹中导入 ionic (cordova) 生成的文件夹 "android"。

cordova 的最新版本正在使用 Gradle 构建系统。因此,如果使用最新版本的 cordova 生成,gradle 构建配置文件已经存在于该 "android" 文件夹中。

通过导入 myapp 文件夹(就像您所做的那样),这些文件不会出现在您的 Android Studio 项目中。因此您会看到错误:This project does not use the Gradle build system.