【问题标题】:How do I include a android library into a cordova plugin如何将android库包含到cordova插件中
【发布时间】:2020-11-05 17:14:52
【问题描述】:

我需要 Ionic 的 document-scanner 插件的定制版本。所以我创建了一个叉子,我可以在我的 ionic 项目中使用我的叉子。但我还需要一个自定义版本的库 scanlibrary 才能在我的自定义文档扫描仪插件中使用它。我按照这个guide 将库添加到我的cordova-plugin 项目中。 不幸的是,当我构建我的 ionic 项目时,该库丢失了。 document-scanner 文件包含在 ionic 项目中,但 AndroidStudio 无法解析扫描库的导入:

这是我的 plugin.xml 文件:

<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" id="cordova-plugin-document-scanner" version="4.2.5">

  <name>Scan</name>
  <engines>
    <engine name="cordova-android" version=">=6.4.0" />
  </engines>
  <asset src="www/scan.js" target="js/scan.js"/>
  <js-module src="www/scan.js" name="scan">
    <clobbers target="scan" />
  </js-module>


  <platform name="android">
    <config-file target="res/xml/config.xml" parent="/*">
      <feature name="Scan">
        <param name="android-package" value="com.neutrinos.plugin.Scan"/>
      </feature>
    </config-file>

    <source-file src="src/android/Scan.java" target-dir="src/com/neutrinos/plugin/" />
    <source-file src="src/android/FileHelper.java" target-dir="src/com/neutrinos/plugin/" />
    <framework src="src/android/build.gradle" custom="true" type="gradleReference"/>
  </platform>


  <platform name="ios">
    <config-file target="config.xml" parent="/*">
      <feature name="Scan">
        <param name="ios-package" value="Scan" />
      </feature>
    </config-file>

    <preference name="CAMERA_USAGE_DESCRIPTION" default="This app needs camera access"/>
    <config-file target="*-Info.plist" parent="NSCameraUsageDescription">
      <string>$CAMERA_USAGE_DESCRIPTION</string>
    </config-file>

    <preference name="PHOTOLIBRARY_USAGE_DESCRIPTION" default="This app needs read/write-access photo library access"/>
    <config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
      <string>$PHOTOLIBRARY_USAGE_DESCRIPTION</string>
    </config-file>

    <header-file src="src/ios/Scan.h" target-dir="ScanPlugin"/>
    <source-file src="src/ios/Scan.m" target-dir="ScanPlugin"/>
    <framework src="src/ios/TOCropViewController.framework" custom="true" embed="true"/>
    <framework src="src/ios/IRLDocumentScanner.framework" custom="true" embed="true"/>
  </platform>

</plugin>

build.gradle 文件:

allprojects {
    repositories {
        maven { 
            url 'https://jitpack.io' 
        }
    }
}

dependencies {
    compile project(':myScanLib')
}

任何想法,完成这项工作缺少什么?

【问题讨论】:

    标签: android cordova ionic-framework


    【解决方案1】:

    据我所知,不可能在 Cordova 项目中包含 Android 本机库。你可以为此创建一个自定义的cordova库

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-21
      • 1970-01-01
      • 2013-06-06
      • 2012-12-03
      • 2018-05-10
      相关资源
      最近更新 更多