问题描述
在过去几天,我无法运行 cordova run android
(或者, ionic run android
)在我的本机设备上测试我的Ionic应用程序。当我运行命令,我得到通常的公吨输出,以及100%CPU使用从几个Java运行时进程,然后该构建最终失败,标题中说明。控制台显示这个(截断,因为有大量的输出):
我刚刚在Android SDK中更新了任何必要的工具和库, - 添加Android平台( cordova平台添加android
),确保检查所有相关的平台文件已经删除,并且项目仍然无法构建。
编辑:我也跑了 cordova clean
,但是没有工作。看起来Google Play服务库使我的应用程序达到64,000方法限制,但除了手动调整我的gradle文件(我不是au fait还有),我不知道我该如何缩小
编辑2:我尝试调整我的build.gradle文件以删除对com.google.android.gms:play-services:+的引用正在推送我的应用程序超过65535方法限制),但它只是不断回来。
我也尝试过build-extras.gradle删除依赖, 。理想情况下,我想要一个答案,不需要每次我想建立我的应用程序,但在这个阶段我几乎渴望几乎任何东西的不断重新工作。
我最近在Windows上升级cordova,ion和bower(使用 npm install -g cordova ionic bower
后,我的%PATH%变量出现了问题,
我运行的是Windows 10,x64。 java -version
reports:
有任何建议吗?
修改 build.gradle
直接不建议,因为更改将在构建Android平台后被覆盖。build.gradle的任何扩展都应该通过添加额外的文件,如'build-extras.gradle' 。根据Grayda的建议,更清洁的解决方案是使用插件,它执行像charm这样的工作。
跨越一个,它执行作业,并且是活动的。您可以使用以下命令安装插件:
cordova插件添加https://github.com/solent/cordova-plugin- multidex
张贴答案,因为它可能会使某人受益。
For the last few days I've been unable to run cordova run android
(or rather, ionic run android
) to test my Ionic app on my native device. When I run the command, I get the usual metric ton of output, along with 100% CPU usage from several Java Runtime processes, then the build finally fails with the stated in the title. The console shows this (truncated, as there's a ton of output):
I just went and updated any necessary tools and libraries in the Android SDK, then I removed and re-added the Android platform (cordova platform add android
), making sure to check that all the relevant platform files were gone, and the project still fails to build.
EDIT: I also ran cordova clean
, but that didn't work. It looks like the Google Play Services library is causing my app to hit the 64,000 method limit, but other than manually tweaking my gradle file (which I'm not au fait with yet), I'm not sure how I can shrink that down
EDIT 2: I tried tweaking my build.gradle file to remove the reference to "com.google.android.gms:play-services:+" (which I think is pushing my app above the 65535 method limit) but it just keeps coming back.
I also tried a build-extras.gradle to remove the dependency, but got another error. Ideally I'd like an answer that doesn't require constant re-working every time I want to build my app, but at this stage I'm keen for pretty much anything.
I did recently upgrade cordova, ionic and bower (using npm install -g cordova ionic bower
after something went screwy with my %PATH% variable on Windows, but I wouldn't imagine that would break anything.
I'm running Windows 10, x64. java -version
reports:
Any suggestions?
Modifying build.gradle
directly is not advisable as the changes will be overwritten after building android platform. Any extensions to build.gradle should be done by adding additional file like 'build-extras.gradle' as suggested in official documentation. As suggested by Grayda, the cleaner solution is to use the plugin which does the job like charm.
Came across one more cordova multiplex plugin which does the job and which is active. You can install the plugin using following command:
cordova plugin add https://github.com/solent/cordova-plugin-multidex
Posting the answer as it may benefit someone out there.
这篇关于cordova运行android失败与com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]:65536的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!