简体   繁体   English

将项目导入Android Studio后无法构建Android应用程序(使用Ionic框架创建)

[英]Unable to build Android app (created with Ionic framework) after importing the project into Android Studio

I'm a complete beginner at creating mobile apps. 我是创建移动应用程序的完整入门者。 I created an Ionic mobile app for Android using Windows and Visual Studio 2017. It works when I use the ionic serve command and try the app in the browser. 我使用Windows和Visual Studio 2017为Android创建了一个Ionic移动应用程序。当我使用ionic serve命令并在浏览器中尝试该应用程序时,该应用程序可以工作。

But when I try to import the project into Android Studio 2.3.3, I get an error message, that it can't build my app: "Gradle sync failed: Failed to find target with hash string 'android-26' in: ...\\AppData\\Local\\Android\\Sdk Gradle sync completed. Gradle build finished with 1 error(s)." 但是,当我尝试将项目导入Android Studio 2.3.3时,收到一条错误消息,提示它无法构建我的应用程序:“等级同步失败:无法在以下位置找到带有哈希字符串'android-26'的目标。 .. \\ AppData \\ Local \\ Android \\ Sdk Gradle同步完成。Gradle构建完成,出现1个错误。

I also get another error message after importing the project into Android Studio, when I try to run the "ionic cordova run android" command in cmd: "An error occured while running cordova run android. FAILURE: Build failed with an exception. Where: ...\\cordova.gradle line 64 将项目导入Android Studio后,当我尝试在cmd中运行“ ionic cordova run android”命令时,我还收到另一条错误消息:“运行cordova run android时发生错误。失败:生成失败,出现异常。其中: ... \\ cordova.gradle第64行

What went wrong: A problem occured evaluating root project 'android'. 出了什么问题:评估根项目“ android”时出现问题。 No installed build tools found. 找不到安装的构建工具。 Install the Android build tools version 19.1.0 or higher." 安装Android构建工具版本19.1.0或更高版本。”

I imported the files into Android Studio choosing Import project (Eclipse,...). 我选择导入项目(Eclipse等)将文件导入Android Studio。 I chose this folder when importing: node_modules\\cordova-android\\spec\\fixtures\\android_project. 我在导入时选择了以下文件夹:node_modules \\ cordova-android \\ spec \\ fixtures \\ android_project。 I'm not sure this is the right folder to choose. 我不确定这是正确的文件夹。

I can see the simulated android phone , I can click on everything, but my app doesn't show up on it. 我可以看到模拟的android手机,可以单击所有内容,但是我的应用程序未显示在上面。 I checked the Android build tools, 25.0.3 and 26.0.2 are installed. 我检查了Android构建工具,已安装25.0.3和26.0.2。 Thank you for the help in advance! 预先感谢您的帮助! I'm really stuck :S 我真的被卡住了:S

Check whether you have set your system PATH variable pointing to android platform tools. 检查您是否已将系统PATH变量设置为指向android平台工具。

Something like : 就像是 :

C:\Users\Lokkeshwaran J\AppData\Local\Android\Sdk\platform-tools

You are choosing Wrong Folder. 您正在选择错误的文件夹。

To open your ionic generated app. 打开您的离子生成的应用程序。 You need to open the following folder in the path: 您需要在路径中打开以下文件夹:

Your_ionic_project/platforms/android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM