我的项目工作正常,直到我尝试实现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": {} } }
我不知道出了什么问题,请任何人帮助我.
<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
在依赖项中添加此行编译’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的行,并对其进行评论或按上述方式执行,谢谢