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

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

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

  1. UNEXPECTED TOP-LEVEL EXCEPTION:
  2. 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文件

  1. {
  2. "name": "app","version": "1.1.1","description": "app: An Ionic project","dependencies": {
  3. "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"
  4. },"devDependencies": {
  5. "bower": "^1.3.3","gulp-util": "^2.2.14","shelljs": "^0.3.0"
  6. },"cordovaPlugins": [
  7. "cordova-plugin-device","cordova-plugin-console","cordova-plugin-whitelist","cordova-plugin-splashscreen","cordova-plugin-statusbar","ionic-plugin-keyboard",{
  8. "locator": "https://github.com/rossmartin/PushPlugin.git","id": "com.phonegap.plugins.PushPlugin"
  9. }
  10. ],"cordovaPlatforms": [
  11. "android"
  12. ]
  13. }

这是我的fetch.json文件

  1. {
  2. "cordova-plugin-device": {
  3. "source": {
  4. "type": "registry","id": "cordova-plugin-device@~1.1.1"
  5. },"is_top_level": true,"variables": {}
  6. },"cordova-plugin-console": {
  7. "source": {
  8. "type": "registry","id": "cordova-plugin-console@~1.0.2"
  9. },"cordova-plugin-whitelist": {
  10. "source": {
  11. "type": "registry","id": "cordova-plugin-whitelist"
  12. },"cordova-plugin-splashscreen": {
  13. "source": {
  14. "type": "registry","id": "cordova-plugin-splashscreen"
  15. },"cordova-plugin-statusbar": {
  16. "source": {
  17. "type": "registry","id": "cordova-plugin-statusbar@~2.1.0"
  18. },"ionic-plugin-keyboard": {
  19. "source": {
  20. "type": "registry","id": "ionic-plugin-keyboard"
  21. },"cordova-plugin-camera": {
  22. "source": {
  23. "type": "registry","id": "cordova-plugin-camera"
  24. },"phonegap-plugin-push": {
  25. "source": {
  26. "type": "registry","id": "phonegap-plugin-push"
  27. },"com.phonegap.plugins.PushPlugin": {
  28. "source": {
  29. "type": "git","url": "https://github.com/phonegap-build/PushPlugin.git","subdir": "."
  30. },"cordova-plugin-datepicker": {
  31. "source": {
  32. "type": "git","url": "https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git","cordova-plugin-calendar": {
  33. "source": {
  34. "type": "registry","id": "cordova-plugin-calendar"
  35. },"cordova-plugin-crosswalk-webview": {
  36. "source": {
  37. "type": "registry","id": "cordova-plugin-crosswalk-webview"
  38. },"variables": {}
  39. }
  40. }

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

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

  1. <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′

  1. dependencies {
  2. compile fileTree(dir: 'libs',include: '*.jar')
  3. // SUB-PROJECT DEPENDENCIES START
  4. debugCompile project(path: "CordovaLib",configuration: "debug")
  5. releaseCompile project(path: "CordovaLib",configuration: "release")
  6. compile "com.android.support:support-v4:+"
  7. // SUB-PROJECT DEPENDENCIES END
  8. compile 'com.android.support:multidex:1.0.1'
  9.  
  10. }

默认配置添加此行multiDexEnabled为true

  1. defaultConfig {
  2. versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")
  3. applicationId privateHelpers.extractStringFromManifest("package")
  4.  
  5. if (cdvMinSdkVersion != null) {
  6. minSdkVersion cdvMinSdkVersion
  7.  
  8. }
  9. multiDexEnabled true
  10. }

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

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

猜你在找的Angularjs相关文章