尝试添加 ngCordova 日历插件后,Ionic Build Android 命令失败并出现异常 [英] Ionic Build Android command fails with an exception after trying to add ngCordova calendar plugin
问题描述
我在 ubuntu 中使用 ionic(1.7.15).
我的项目运行良好,直到我尝试实现
意外的顶级异常:com.android.dex.DexException: 多个 dex 文件定义了 Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
我希望由于我的项目中有多个插件而出现上述错误有什么解决方案.我发现此错误与 此处.
我尝试过的:
我已经尝试升级我的 android SDK.
使用此堆栈溢出问题无法解决所有配置依赖项':_armv7DebugCompile' 之后我已经完成了所有操作,我收到了上述错误.
这是我的 package.json 文件
<代码>{"name": "应用程序","版本": "1.1.1","description": "app: 一个 Ionic 项目",依赖关系":{"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"},开发依赖":{"凉亭": "^1.3.3","gulp-util": "^2.2.14",shelljs":^0.3.0"},科尔多瓦插件":["cordova-plugin-device","cordova-plugin-console","cordova-plugin-whitelist","cordova-plugin-splashscreen","cordova-plugin-statusbar",离子插件键盘",{"locator": "https://github.com/rossmartin/PushPlugin.git","id": "com.phonegap.plugins.PushPlugin"}],科尔多瓦平台":[安卓"]}
这是我的 fetch.json 文件
<代码>{科尔多瓦插件设备":{来源": {"type": "注册表","id": "cordova-plugin-device@~1.1.1"},is_top_level":真,变量":{}},科尔多瓦插件控制台":{来源": {"type": "注册表","id": "cordova-plugin-console@~1.0.2"},is_top_level":真,变量":{}},科尔多瓦插件白名单":{来源": {"type": "注册表","id": "cordova-plugin-whitelist"},is_top_level":真,变量":{}},cordova-plugin-splashscreen":{来源": {"type": "注册表","id": "cordova-plugin-splashscreen"},is_top_level":真,变量":{}},cordova-plugin-statusbar":{来源": {"type": "注册表","id": "cordova-plugin-statusbar@~2.1.0"},is_top_level":真,变量":{}},离子插件键盘":{来源": {"type": "注册表",id":离子插件键盘"},is_top_level":真,变量":{}},科尔多瓦插件相机":{来源": {"type": "注册表","id": "cordova-plugin-camera"},is_top_level":真,变量":{}},phonegap-plugin-push":{来源": {"type": "注册表","id": "phonegap-plugin-push"},is_top_level":真,变量":{}},com.phonegap.plugins.PushPlugin":{来源": {"类型": "git","url": "https://github.com/phonegap-build/PushPlugin.git",子目录":."},is_top_level":真,变量":{}},cordova-plugin-datepicker":{来源": {"类型": "git","url": "https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git",子目录":."},is_top_level":真,变量":{}},科尔多瓦插件日历":{来源": {"type": "注册表","id": "cordova-plugin-calendar"},is_top_level":真,变量":{}},cordova-plugin-crosswalk-webview":{来源": {"type": "注册表","id": "cordova-plugin-crosswalk-webview"},is_top_level":真,变量":{}}}
我不知道出了什么问题,请任何人帮助我.
您的问题是您使用的是过时版本的推送插件.从您的 package.json
,您包括 https://github.com/rossmartin/PushPlugin.git 这是一个已弃用的插件的未维护分支,该插件已 2 年未更新.因此,如果您查看它的 plugin.xml
,您可以看到它 包括作为 JAR 的 Android 支持库,用于旧的 Ant 驱动的 Cordova 构建过程:
<source-file src="src/android/com/plugin/android-support-v13.jar" target-dir="libs/"/>
您需要删除此版本的插件并将其替换为 最新版本 cordova-plugin-push
,其中 使用 Gradle 来包含支持库:
<framework src="com.android.support:support-v13:23+"/>
请注意,您需要为 Android API v23 构建,因此必须通过 SDK 管理器安装它,并使用 Cordova Android 平台 v5+ (cordova-android@5+
).>
更新
在 build.gradle 文件中,我添加了这几行.
在依赖项中添加这一行 compile 'com.android.support:multidex:1.0.1'
依赖项 {编译文件树(目录:'libs',包括:'*.jar')//子项目依赖开始调试编译项目(路径:CordovaLib",配置:调试")发布编译项目(路径:CordovaLib",配置:发布")编译com.android.support:support-v4:+"//子项目依赖结束编译'com.android.support:multidex:1.0.1'}
默认配置添加这一行multiDexEnabled true
defaultConfig {versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")applicationId privateHelpers.extractStringFromManifest("package")如果(cdvMinSdkVersion != null){minSdkVersion cdvMinSdkVersion}multiDexEnabled true}
添加此行后,我收到了他的错误引用此网站我通过删除 platform/android/libs/ 解决了它你可以看到 "android-support-v13.jar" 删除那个文件
为项目安装的所有插件查找 plugin.xml 文件,然后检查冷藏到该 android-support-v13.jar 的任何行并对其进行评论或按上述操作,谢谢你
I am working ionic(1.7.15) in ubuntu.
My project works fine until i try to implement calendar plugin. After installing this plugin to my project and i try to build with ionic build android
command but i am getting the following error.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
I hope the above error occurs due to multiple plugin in my project is there any solution. I found this error is related to multidex
from here.
What i have tried:
I have tried the upgrading my android SDK.
Using this stack-overflow question Could not resolve all dependencies for configuration ':_armv7DebugCompile' i have done all after that i am getting the above error.
Here is my package.json file
{
"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"
]
}
Here is my fetch.json file
{
"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"
},
"is_top_level": true,
"variables": {}
},
"cordova-plugin-whitelist": {
"source": {
"type": "registry",
"id": "cordova-plugin-whitelist"
},
"is_top_level": true,
"variables": {}
},
"cordova-plugin-splashscreen": {
"source": {
"type": "registry",
"id": "cordova-plugin-splashscreen"
},
"is_top_level": true,
"variables": {}
},
"cordova-plugin-statusbar": {
"source": {
"type": "registry",
"id": "cordova-plugin-statusbar@~2.1.0"
},
"is_top_level": true,
"variables": {}
},
"ionic-plugin-keyboard": {
"source": {
"type": "registry",
"id": "ionic-plugin-keyboard"
},
"is_top_level": true,
"variables": {}
},
"cordova-plugin-camera": {
"source": {
"type": "registry",
"id": "cordova-plugin-camera"
},
"is_top_level": true,
"variables": {}
},
"phonegap-plugin-push": {
"source": {
"type": "registry",
"id": "phonegap-plugin-push"
},
"is_top_level": true,
"variables": {}
},
"com.phonegap.plugins.PushPlugin": {
"source": {
"type": "git",
"url": "https://github.com/phonegap-build/PushPlugin.git",
"subdir": "."
},
"is_top_level": true,
"variables": {}
},
"cordova-plugin-datepicker": {
"source": {
"type": "git",
"url": "https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git",
"subdir": "."
},
"is_top_level": true,
"variables": {}
},
"cordova-plugin-calendar": {
"source": {
"type": "registry",
"id": "cordova-plugin-calendar"
},
"is_top_level": true,
"variables": {}
},
"cordova-plugin-crosswalk-webview": {
"source": {
"type": "registry",
"id": "cordova-plugin-crosswalk-webview"
},
"is_top_level": true,
"variables": {}
}
}
I have no idea about what went wrong please anyone help me.
Your problem is you are using an outdated version of the push plugin. From your package.json
, you are including https://github.com/rossmartin/PushPlugin.git which is a unmaintained branch of a deprecated plugin that hasn't been updated in 2 years. Hence, if you look at its plugin.xml
, you can see it includes the Android Support Library as a JAR for the legacy Ant-driven Cordova build process:
<source-file src="src/android/com/plugin/android-support-v13.jar" target-dir="libs/" />
You need to remove this version of the plugin and replace it with the up-to-date equivalent cordova-plugin-push
, which uses Gradle to include the support library:
<framework src="com.android.support:support-v13:23+" />
Note you will need to build for Android API v23, so must have this installed via the SDK Manager and be using v5+ of the Cordova Android platform (cordova-android@5+
).
UPDATE
In build.gradle file i add this lines.
In dependencies add this line compile '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'
}
default config add this line multiDexEnabled true
defaultConfig {
versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")
applicationId privateHelpers.extractStringFromManifest("package")
if (cdvMinSdkVersion != null) {
minSdkVersion cdvMinSdkVersion
}
multiDexEnabled true
}
After adding this lines then i got his error reffer this website and i solved it by removing platform/android/libs/ You can see "android-support-v13.jar" delete that file
all your plugin that have been installed for project look for plugin.xml file and then check any line that reefer to that android-support-v13.jar and comment it or do as above, thank you
这篇关于尝试添加 ngCordova 日历插件后,Ionic Build Android 命令失败并出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!