Cordova插件-添加第三方SDK [英] Cordova Plugin - Add third party sdk

查看:634
本文介绍了Cordova插件-添加第三方SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为以下sdk创建插件- https ://ktplayhelp.zendesk.com/hc/en-us/articles/221071888-Android

I am trying to create the plugin for the following sdk - https://ktplayhelp.zendesk.com/hc/en-us/articles/221071888-Android

在设置项目的配置点,它告诉您通过在Android Studio中导入模块来设置sdk,并将依赖项添加到我们应用程序的build.gradle文件中.

In the setup project configuration point it is telling to setup the sdk by importing module in Android studio and add the dependency in our application's build.gradle file.

任何人都可以帮忙,告诉我如何在不使用Android Studio的情况下在Cordova中导入Android本机模块吗?

Can anyone please help and tell me how can I import the Android native module in Cordova without using Android studio?

推荐答案

由于您无法修改cordovas .gradle文件,因此必须添加自己的文件并在plugin.xml中引用它,您可以像这样进行操作:

As you can't modify cordovas .gradle file you have to add your own and reference it in your plugin.xml you can do that like this:

<framework src="src/android/*.gradle" custom="true" type="gradleReference" />

这将允许您执行诸如编译外部模块之类的事情.为了使它真正起作用,您将不得不在要集成的项目之外创建一个.aar库.

This will allow you to do things like compiling an external module. To make this actually work you will have to create an .aar library out of the project you want to integrate.

产生的gradle-extension看起来像这样:

The resulting gradle-extension will look something like this:

repositories {    
    jcenter()
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile(name:'KTplay', ext:'aar')
}

android {
    packagingOptions {
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }
}

这假定您已将.aar库放在名为libs的插件的子目录中.剩下要做的就是确保在构建过程中确实复制了库,这就是为什么我们必须将其作为资源文件添加到plugin.xml:

This assumes that you have put your .aar library in a subdirectory of your plugin named libs. Whats left to do is to ensure that the library actually gets copied during the build process, this is why we have to add it as a resource file in plugin.xml:

<resource-file src="libs/KTplay.aar" target="libs/KTplay.aar" />

这篇关于Cordova插件-添加第三方SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆