angularjs – Ionic Build Android命令在尝试添加ngCordova日历插件后失败并出现异常

前端之家收集整理的这篇文章主要介绍了angularjs – Ionic Build Android命令在尝试添加ngCordova日历插件后失败并出现异常前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在ubuntu工作离子(1.7.15).

我的项目工作正常,直到我尝试实现calendar插件.将此插件安装到我的项目后,我尝试使用ionic build android命令构建,但我收到以下错误.

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

我希望上面的错误是由于我的项目中的多个插件有任何解决方案.我发现这个错误here的multidex有关.

我尝试过的:

我试过升级我的android SDK.

使用这个堆栈溢出问题Could not resolve all dependencies for configuration ‘:_armv7DebugCompile’我已经完成了所有我得到上述错误.

这是我的package.json文件

{
  "name": "app","version": "1.1.1","description": "app: An Ionic project","dependencies": {
    "gulp": "^3.5.6","gulp-sass": "^2.0.4","gulp-concat": "^2.2.0","gulp-minify-css": "^0.3.0","gulp-rename": "^1.2.0"
  },"devDependencies": {
    "bower": "^1.3.3","gulp-util": "^2.2.14","shelljs": "^0.3.0"
  },"cordovaPlugins": [
    "cordova-plugin-device","cordova-plugin-console","cordova-plugin-whitelist","cordova-plugin-splashscreen","cordova-plugin-statusbar","ionic-plugin-keyboard",{
      "locator": "https://github.com/rossmartin/PushPlugin.git","id": "com.phonegap.plugins.PushPlugin"
    }
  ],"cordovaPlatforms": [
    "android"
  ]
}

这是我的fetch.json文件

{
    "cordova-plugin-device": {
        "source": {
            "type": "registry","id": "cordova-plugin-device@~1.1.1"
        },"is_top_level": true,"variables": {}
    },"cordova-plugin-console": {
        "source": {
            "type": "registry","id": "cordova-plugin-console@~1.0.2"
        },"cordova-plugin-whitelist": {
        "source": {
            "type": "registry","id": "cordova-plugin-whitelist"
        },"cordova-plugin-splashscreen": {
        "source": {
            "type": "registry","id": "cordova-plugin-splashscreen"
        },"cordova-plugin-statusbar": {
        "source": {
            "type": "registry","id": "cordova-plugin-statusbar@~2.1.0"
        },"ionic-plugin-keyboard": {
        "source": {
            "type": "registry","id": "ionic-plugin-keyboard"
        },"cordova-plugin-camera": {
        "source": {
            "type": "registry","id": "cordova-plugin-camera"
        },"phonegap-plugin-push": {
        "source": {
            "type": "registry","id": "phonegap-plugin-push"
        },"com.phonegap.plugins.PushPlugin": {
        "source": {
            "type": "git","url": "https://github.com/phonegap-build/PushPlugin.git","subdir": "."
        },"cordova-plugin-datepicker": {
        "source": {
            "type": "git","url": "https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git","cordova-plugin-calendar": {
        "source": {
            "type": "registry","id": "cordova-plugin-calendar"
        },"cordova-plugin-crosswalk-webview": {
        "source": {
            "type": "registry","id": "cordova-plugin-crosswalk-webview"
        },"variables": {}
    }
}

我不知道出了什么问题,请任何人帮助我.

您的问题是您使用的是推送插件的过时版本.从你的package.json中,你包含了 https://github.com/rossmartin/PushPlugin.git,它是一个不受约束的插件的未维护分支,该插件在2年内没有更新.因此,如果你看看它的plugin.xml,你可以看到 includes the Android Support Library as a JAR用于传统的Ant驱动的Cordova构建过程:
<source-file src="src/android/com/plugin/android-support-v13.jar" target-dir="libs/" />

您需要删除此版本的插件并将其替换为uses Gradle to include the support library cordova-plugin-push,其中uses Gradle to include the support library

<framework src="com.android.support:support-v13:23+" />

请注意,您需要为Android API v23构建,因此必须通过SDK Manager安装并使用Cordova Android平台的v5(cordova-android @ 5).

UPDATE

在build.gradle文件中,我添加这一行.

在依赖项中添加此行编译’com.android.support:multidex:1.0.1′

dependencies {
    compile fileTree(dir: 'libs',include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile project(path: "CordovaLib",configuration: "debug")
    releaseCompile project(path: "CordovaLib",configuration: "release")
    compile "com.android.support:support-v4:+"
    // SUB-PROJECT DEPENDENCIES END
    compile 'com.android.support:multidex:1.0.1' 

}

默认配置添加此行multiDexEnabled为true

defaultConfig {
        versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")
        applicationId privateHelpers.extractStringFromManifest("package")

        if (cdvMinSdkVersion != null) {
            minSdkVersion cdvMinSdkVersion

        }
        multiDexEnabled true
    }

添加这行后,我得到了他的错误reffer这website我通过删除platform / android / libs解决了它你可以看到“android-support-v13.jar”删除文件

你为项目安装的所有插件都会查找plugin.xml文件,然后查看任何反映到android-support-v13.jar的行,并对其进行评论或按上述方式执行,谢谢

原文链接:https://www.f2er.com/angularjs/143273.html

猜你在找的Angularjs相关文章