简体   繁体   English

如何将Google Play服务添加到Ionic Android Project?

[英]How can I add google play services to Ionic Android Project?

I am trying to make this plugin work with my ionic app: 我正在尝试使该插件与我的离子应用程序一起使用:

https://github.com/pmwisdom/cordova-background-geolocation-services https://github.com/pmwisdom/cordova-background-geolocation-services

This plugin needs Google Play Services installed to work. 此插件需要安装Google Play服务才能运行。

I have installed it through android SDK and followed this steps in order to get the library included into my project: 我已经通过android SDK安装了它,并按照以下步骤进行操作,以使该库包含在我的项目中:

https://developer.android.com/tools/projects/projects-cmdline.html#ReferencingLibraryProject https://developer.android.com/tools/projects/projects-cmdline.html#ReferencingLibraryProject

Now if I try to build android project I get: 现在,如果我尝试构建android项目,则会得到:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Cannot evaluate module google-play-services_lib : Configuration with name 'debug' not found.

From some research It seems like that this problem is related to project structure and gradle, but I can't figure out how to solve it. 从一些研究看来,这个问题似乎与项目结构和gradle有关,但是我不知道该如何解决。 Can anybody help me? 有谁能够帮助我?

I can also evaluate different free background gps plugins to run into my ionic app. 我还可以评估不同的免费背景gps插件以运行到我的离子应用程序中。

Thank you 谢谢

In Creating an Android Module , after installing minimum required SDK, you have the following options: 在安装最低必需的SDK之后,在创建Android模块中 ,您可以使用以下选项:

  • Set up a Library Module so you can create a new one in the same way as you would create a new application module. 设置一个库模块,以便您可以像创建一个新的应用程序模块一样创建一个新的库模块。 With Library Module being set up, you can easily change an existing application module to a library module by changing the plugin assignment in the build.gradle file to com.android.library . 通过设置库模块,您可以通过将build.gradle文件中的插件分配更改为com.android.library来轻松地将现有应用程序模块更改为库模块。

  • Add a dependency on a library module by declaring all of the shared components that it includes in the module's manifest file. 通过声明它包含在模块清单文件中的所有共享组件, 在库模块上添加依赖项 To add the dependency declaration to the build file, edit the build file for the app module ( app/build.gradle ) and add a dependency on the lib module. 要将依赖项声明添加到构建文件,请编辑app模块的构建文件( app/build.gradle )并在lib模块上添加依赖项。

  • Reference a library module with these steps: 通过以下步骤引用库模块

    1. Make sure that both the module library and the application module that depends on it are in your project. 确保模块库和依赖它的应用程序模块都在您的项目中。 If one of the modules is missing, import it into your project. 如果缺少其中一个模块,请将其导入到您的项目中。

    2. In the project view, right-click the dependent module and select Open > Module Settings. 在项目视图中,右键单击相关模块,然后选择“ 打开”>“模块设置”。

    3. Right-click the plus icon to add a new dependencies. 右键单击加号图标以添加新的依赖项。 If you are adding references to multiple libraries, you can set their relative priority (and merge order) by selecting a library and using the Up and Down controls. 如果要向多个库添加引用,则可以通过选择一个库并使用“向上”和“向下”控件来设置它们的相对优先级(和合并顺序)。
    4. Use the Scope drop-down to select how the dependency will be applied. 使用“ 范围”下拉列表选择将如何应用依赖项。
    5. Click Apply to create the dependency and OK to close the Project Structure window. 单击“ 应用”创建依赖关系,然后单击“确定”关闭“ 项目结构”窗口。
  • Declare library components in the manifest file . 在清单文件中声明库组件 You must add declarations of all components that the applications will use that are imported from a library module. 您必须添加从库模块导入的应用程序将使用的所有组件的声明。 For example, you must declare any < activity >, < service >, < receiver >, < provider >, and so on, as well as < permission >, < uses-library >, and similar elements. 例如,您必须声明任何< activity >,< service >,< receiver >,< provider >等,以及< permission >,< uses-library >和类似元素。

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

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