首页 > 解决方案 > Cordova Android 插件失败

问题描述

我有一个我正在尝试创建的 Cordova 插件

我有一个看起来像这样的文件夹结构

- src/
  - android/
    - *.java
    - infinitumscanner.aar
    - infinitumscanner.gradle
- www/
    - *.js
- plugin.xml

我的 plugin.xml 看起来像这样

在 gradle 我有以下代码,依赖项是 .aar 文件使用的

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

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.google.android.gms:play-services-vision:20.1.3'
    implementation 'com.google.code.gson:gson:2.8.6'    
    implementation files('libs/infinitumscanner.aar')
}

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

在我的 Cordova 应用程序中,当我使用时cordova build出现以下错误,我通过使用安装了插件cordova plugin add ../ScannerPlugin

D:\Cordova\TestApp>cordova build
cordova-plugin-androidx: Updated gradle.properties to enable AndroidX
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:\AndroidSdk (recommended setting)
ANDROID_HOME=C:\AndroidSdk (DEPRECATED)
Using Android SDK: C:\AndroidSdk
> Task :app:processDebugManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform infinitumscanner.aar to match attributes {artifactType=android-manifest}.
      > Execution failed for JetifyTransform: D:\Cordova\TestApp\platforms\android\app\libs\infinitumscanner.aar.
         > Failed to transform 'D:\Cordova\TestApp\platforms\android\app\libs\infinitumscanner.aar' using Jetifier. Reason: FileNotFoundException, message: D:\Cordova\TestApp\platforms\android\app\libs\infinitumscanner.aar (The system cannot find the path specified). (Run with --stacktrace for more details.)
           Please file a bug at http://issuetracker.google.com/issues/new?component=460323.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 14s
21 actionable tasks: 2 executed, 19 up-to-date
Command failed with exit code 1: D:\Cordova\TestApp\platforms\android\gradlew cdvBuildDebug -b D:\Cordova\TestApp\platforms\android\build.gradle

标签: androidcordova-plugins

解决方案


推荐阅读