如何解决 INSTALL_FAILED_DEXOPT 错误?

发布于 2024-10-19 20:30:22 字数 164 浏览 5 评论 0原文

我正在使用 Android 2.2 开发 Android 应用程序,我的应用程序 APK 大小为 22.5 MB,我想为三星平板电脑创建新版本。我收到以下错误:

INSTALL_FAILED_DEXOPT

如何解决此类错误?

I am developing an Android application using Android 2.2, my application APK size is 22.5 MB, and I would like to create a new build for a Samsung tablet. I got the following error:

INSTALL_FAILED_DEXOPT

How do I solve this kind of error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(30

壹場煙雨 2024-10-26 20:30:22

这对我来说似乎与磁盘空间有关。新推出的 5.1 模拟器启动时出现“磁盘空间不足”错误 - 查看模拟器属性,分配给内部存储的默认空间为 800MB,这似乎很低。

因此,解决方案是增加这个(我增加到 4GB)。奇怪的是,模拟器启动时仍然出现相同的磁盘空间警告,但工厂重置它(设置 - >模拟器内的备份和恢复)完全为我解决了这个问题。

只是有点奇怪,它在默认设置下不能开箱即用。

This seemed to be related to disk space for me. A newly rolled 5.1 emulator boots with a "low on disk space" error - and looking at the emulator properties, the default space allocated for internal storage is 800MB which seems low.

Solution, therefore was to increase this (I went to 4GB). Oddly the emulator still boots with the same disk space warning but factory resetting it (Settings --> Backup and Restore inside the emulator) solved it entirely for me.

Just a bit odd that it doesn't work out of the box with default settings.

遮了一弯 2024-10-26 20:30:22

从 Android SDK 和 AVD Manager 重新启动模拟器并选择选项“擦除用户数据”已经为我解决了这个问题。

您可以找到下图中突出显示的选项:

启动 Android 模拟器时擦除用户数据选项

Restarting the emulator from the Android SDK and AVD Manager and selecting the option Wipe User Data has solved this problem for me.

You can find the option as highlighted in the below given image:

Wipe User Data option when starting android emulator

聊慰 2024-10-26 20:30:22

您正在安装的旧版本应用程序具有已更改的依赖库/jar。我在更新我的应用程序引用的其他 jar 文件时遇到了这个问题。

您将需要卸载旧版本,然后就不会有更多问题了...

设置-->应用程序-->管理应用程序-->[查找并卸载您的应用程序]

INSTALL_FAILED_DEXOPT 错误不应爆发。就像

[2011-06-14 01:23:40 - ProtectYourself] Installing ProtectYourself.apk...
[2011-06-14 01:24:26 - ProtectYourself] Installation error: INSTALL_FAILED_DEXOPT
[2011-06-14 01:24:26 - ProtectYourself] Please check logcat output for more details.
[2011-06-14 01:24:26 - ProtectYourself] Launch canceled!

呼呼。

Your old version of the app that you are installing has dependent libraries / jars that have been changed. I ran into this issue when updating other jar files that my app was refrencing.

You will need to Uninstall your old version and then you should have no more issues...

Settings-->Applications-->Manage Applications-->[Find and Uninstall your App]

INSTALL_FAILED_DEXOPT errors should not erupt. Like

[2011-06-14 01:23:40 - ProtectYourself] Installing ProtectYourself.apk...
[2011-06-14 01:24:26 - ProtectYourself] Installation error: INSTALL_FAILED_DEXOPT
[2011-06-14 01:24:26 - ProtectYourself] Please check logcat output for more details.
[2011-06-14 01:24:26 - ProtectYourself] Launch canceled!

Whoo hoo.

与君绝 2024-10-26 20:30:22

使用 Android Studio 3.4.1 但使用较旧的 (5.0) 模拟器时遇到了这个问题。 此过程(在 Mac 上)修复了问题:

  1. 停止模拟器
  2. cd ~/.android/avd/[模拟器名称].avd
  3. rm *.lock
  4. 擦除模拟器
  5. 启动模拟器

Ran into this with Android Studio 3.4.1 but using an older (5.0) emulator. This procedure (on Mac) fixed the issue:

  1. stop emulator
  2. cd ~/.android/avd/[emulator name].avd
  3. rm *.lock
  4. wipe emulator
  5. start emulator
少钕鈤記 2024-10-26 20:30:22

如果您使用的是 Android Studio,请尝试清理您的项目:

Build >清洁工程

If you are using Android Studio, try clean your project:

Build > Clean Project

冷情 2024-10-26 20:30:22

看来此错误消息可能有许多不同的原因。我遇到的案例是在真实设备上(因此模拟器基础解决方案不适用)。

基本上,当发生这种情况时,将 Logcat 过滤器设置为详细警告,这将帮助您获取有关原因的更多信息。

就我而言,我正在处理的项目(一个大型现有代码库)中包含了多个或相互冲突的 JUnit 版本。我尝试部署的 Android 应用程序有多个库项目作为依赖项,并且我错误地将其设置为包含多个 JUnit jar 文件。

我根据一系列 Logcat 消息发现了这一点。请注意,WARN 行给出了原因:

DEBUG/dalvikvm(4808): DexOpt: 'Ljunit/framework/TestSuite$1;' has an earlier definition; blocking out
11-06 14:30:10.973: WARN/dalvikvm(4808): Invalid file flags in class Ljunit/runner/Sorter$Swapper;: 0209
11-06 14:30:10.973: null/libc(4808): Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 4808 (dexopt)

It seems like this error message can have many different causes. The case I came across was on a real device (so the emulator bases solutions did not apply).

Basically, when this happens, set your Logcat filter to Verbose or Warn, which will help you get more information about the cause.

In my case, multiple or conflicting versions of JUnit were being included in the project I was working on (a large existing codebase). The Android app I was trying to deploy had several library projects as dependencies, and I had mistakenly set things up to include multiple JUnit jar files.

I discovered this based on a series of Logcat messages. Note that the WARN line gives the cause:

DEBUG/dalvikvm(4808): DexOpt: 'Ljunit/framework/TestSuite$1;' has an earlier definition; blocking out
11-06 14:30:10.973: WARN/dalvikvm(4808): Invalid file flags in class Ljunit/runner/Sorter$Swapper;: 0209
11-06 14:30:10.973: null/libc(4808): Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 4808 (dexopt)
失而复得 2024-10-26 20:30:22

我在 eclipse AVD 管理器中更改了模拟器的RAM 大小和内部存储容量现在正在工作...

I' changed the RAM size and internel storage capacity of the emulator Now IT IS Working... in eclipse AVD manager

我一直都在从未离去 2024-10-26 20:30:22

尝试我的答案 https://stackoverflow.com/a/34918549/3737254

如果您使用 android studio 2.0,请禁用即时跑步。

仅供参考,即时运行是 android studio 2.0 的新功能(我从未使用过它>。<)

如何禁用:首选项 ->构建、执行和部署->即时运行->禁用,然后像魔术一样工作

享受!

try my answer https://stackoverflow.com/a/34918549/3737254

if you use android studio 2.0, DISABLE the instant run.

FYI, instant run is new feature from android studio 2.0 (i never used it >.<)

how to disable : preferences -> build, execution & deployment -> instant run -> disable, then works like magic

Enjoy!

木有鱼丸 2024-10-26 20:30:22

对我来说解决这个问题的唯一解决方案是将虚拟机的 RAM 增加到 4GB。

The only solution that worked for me to fixed this was to increase the VM's RAM to 4GB.

給妳壹絲溫柔 2024-10-26 20:30:22

我需要禁用即时运行来解决该问题。要在 OS X 上禁用 Instant Run,请转至 Android Studio > 首选项 > 构建、执行、部署 > 即时运行然后删除启用即时运行以在部署时热交换代码/资源更改(默认启用) 中的勾选。

I needed to disable Instant Run to fix the issue. To disable Instant Run on OS X, go to Android Studio > Preferences > Build, Execution, Deployment > Instant Run then remove the tick from Enable Instant Run to hot swap code/resource changes on deploy (default enabled).

数理化全能战士 2024-10-26 20:30:22

今天我在新的虚拟设备上使用 Android Studio 时遇到了同样的问题。看起来我已经下载了 x86_64 映像,并使用等效的 x86 映像重新创建 VD 修复了该问题。

在这种情况下,我预计会得到 INSTALL_FAILED_NO_MATCHING_ABIS,但不知何故,我被 INSTALL_FAILED_DEXOPT 困住了

I had the same issue today with Android Studio on a new virtual device. It appeared I had downloaded the x86_64 image, recreating the VD with the equivalent x86 image fixed it.

I expected to get a INSTALL_FAILED_NO_MATCHING_ABIS in this case but somehow I was stuck with INSTALL_FAILED_DEXOPT

煮酒 2024-10-26 20:30:22

我正在使用 Android Studio 并遇到了同样的错误。

删除主模块的构建文件夹会有所帮助。删除后一切恢复正常。

I am working with Android Studio and had the same error.

Deleting the build folder of the main Modul helped. After deleting everything get back to normal.

独孤求败 2024-10-26 20:30:22

INSTALL_FAIL_DEXOPT 通常与classes.dex 上的限制有关。对于 ICS 之前的任何内容,dexopt 在任何超过 5 MB 的内容上都会失败。最新版本的 Android 使用 8 或 16 MB 缓冲区。

检查 APK 中classes.dex 的大小。最好看看您的方法计数是多少,因为 dex 有 65536 个方法/字段限制。


参考文献:

安装应用程序时出错 (INSTALL_FAILED_DEXOPT)

https://www.facebook .com/notes/facebook-engineering/under-the-hood-dalvik-patch-for-facebook-for-android/10151345597798920

如何收缩代码 - dex 中的 65k 方法限制

INSTALL_FAIL_DEXOPT usually has to do with the limit placed on classes.dex. On anything pre-ICS dexopt will fail on anything over 5 MB. Recent versions of Android use an 8 or 16 MB buffer.

Check the size of classes.dex in your APK. It would also be good to see what your method count is, as dex has a 65536 method/field limit.


References:

Error while installing application (INSTALL_FAILED_DEXOPT)

https://www.facebook.com/notes/facebook-engineering/under-the-hood-dalvik-patch-for-facebook-for-android/10151345597798920

How to shrink code - 65k method limit in dex

北笙凉宸 2024-10-26 20:30:22

验证您设备上的存储空间

verify the storage space on your device

岛徒 2024-10-26 20:30:22

在构建中启用 jumboMode 标志 (dex.force.jumbo=true) 后,我遇到了这个问题。在较新的 Android 设备上一切正常,但在 Gingerbread 上安装失败。

因此,如果您的应用程序由于烦人的 65k 限制而需要巨型模式,请尝试删除一些未使用的代码/字符串并将巨型模式设置回 false。

I ran into this problem after enabling the jumboMode flag in the build (dex.force.jumbo=true). Everything worked fine on newer Android devices, but installation failed on Gingerbread.

So if your app requires jumbo mode due to the annoying 65k restriction, try cutting some unused code/strings and setting jumbo mode back to false.

断爱 2024-10-26 20:30:22

classes.dex 未进入最终的.apk。运行 gradlew --offline clean && gradlew --offline assembleDebug 每次都为我解决问题。从那时起,您可以再次从 Android Studio 启动应用程序。

编辑:在我上面说的之前,请转到任务管理器并杀死所有 cmd.execonhost.exe 进程(或者仅杀死 aapt 进程) > 被卡住了)。否则,从现在开始从命令行启动时,aapt 将会崩溃,并出现臭名昭著的错误 -1073741819

classes.dex does not make it to the final .apk. Running gradlew --offline clean && gradlew --offline assembleDebug fixed things for me every time. From that point you can start launching the app from Android Studio again.

EDIT: Before what I said above go to Task Manager and kill all cmd.exe and conhost.exe processes (or just the one in which aapt got stuck). Otherwise aapt would crash from now on when launched from command line with the infamous error -1073741819.

就是爱搞怪 2024-10-26 20:30:22

我遇到了同样的错误,并通过增加内部存储的大小来修复它。

内部存储最初设置为 32MB(我知道),然后我在上面安装了几个 apk,留下的空间比安装所需的空间要少。

I got the same error and fixed it by increasing the size of internal storage.

The internal storage was initially set to 32MB(I know) and then I installed a couple of apks on it, which had left less space than what was needed for the one to be installed.

眼中杀气 2024-10-26 20:30:22

我卸载了该应用程序,但仍然收到 INSTALL_FAILED_DEXOPT 错误。
如果您正在使用 Android Studio / gradle:gradle clean 为我做到了这一点,
干杯。

I had the app uninstalled and got the INSTALL_FAILED_DEXOPT error nevertheless.
If you are working with Android Studio / gradle: gradle clean did the trick for me,
Cheers.

似最初 2024-10-26 20:30:22

在构建.gradle
将已编译并构建更改为最新版本。这对我有用。

===============

android {
    compileSdkVersion 22
    buildToolsVersion "22"

in build.gradle
change compiled and build to latest version. and it worked for me.

================

android {
    compileSdkVersion 22
    buildToolsVersion "22"
栖迟 2024-10-26 20:30:22

我发现这个问题的原因只有一个:手机空间不足。于是我删除了手机上的几个APP就解决了。

I found there's one reason for this problem: not enough space on mobile. So I delete several APP from mobile and it's fixed.

摘星┃星的人 2024-10-26 20:30:22

这里有很多答案,但也许它可以帮助某人
我在真实设备上遇到了这个问题,问题是 D8

尝试将其添加到您的 gradle.properties 中,它对我有用

android.enableD8=false
android.enableD8.desugaring= false

a lot of answers here, but maybe it can help someone
I had this issue with real device and problem was with D8

try to add this to your gradle.properties and it works for me

android.enableD8=false
android.enableD8.desugaring= false
自此以后,行同陌路 2024-10-26 20:30:22

我在尝试在 2.3 设备上安装时遇到了这个问题(在 4.0.3 上没问题)。它最终是由于我正在使用的一个lib项目有多个jar,这些jar用于android中已经存在的东西,例如HttpClient和XML解析器等。查看logcat让我找到了这个,因为它告诉我它由于他们已经在场而逃课。那里有一个很好的无用的原始错误!

I was getting this issue when trying to install on 2.3 devices (fine on 4.0.3). It ended up being due to a lib project i was using had multiple jars which were for stuff already in android e.g. HttpClient and XML parsers etc. Looking at logcat led me to find this as it was telling me it was skipping classes due to them already being present. Nice unhelpful original error there!

牵你手 2024-10-26 20:30:22

我在真实设备上测试了这个错误。清除缓存/卸载、重新启动一切对我来说都不起作用,删除构建文件夹的内容却有效:)(Android studio)

I had this error testing on a real device. Clearing cache/uninstalling, restarting everything didn't work for me, deleting the contents of the build folder did :) (Android studio)

夜声 2024-10-26 20:30:22

没有通用的解决方案,您必须找到 Logcat 上报告的错误才能解决问题。有时,由于使用了指定目标 API 上不可用的类,因此该类无法“dexed”。或者它可能是您在代码中引用的类,但它所在的库没有被打包。

There's no generic solution, you have to find the error reported on your Logcat to be able to figure it out. Sometimes it's a class that can't be 'dexed' due to an usage of a class not available on the specified Target API for instance. Or it could be a class that you're making reference in your code, but the library that it is in is not being packaged.

假扮的天使 2024-10-26 20:30:22

考虑使用 proguard 来缩小您的 APK。如果我尝试在旧的 Samsung Galaxy Ace 2.3.6 设备上安装一个 25MB+ 的大 APK,而不使用 proguard 缩小/优化代码,我也会遇到同样的问题。

巨型模式和重新启动设备不起作用。

Consider using proguard to shrink your APK. I have the same issue if I try to install a large 25MB+ APK on an old Samsung Galaxy Ace 2.3.6 device without shrinking/optimizing code with proguard.

Jumbo mode and restarting the device is not working.

物价感观 2024-10-26 20:30:22

中的错误

就我而言,这是 kotlin 插件版本 1.1.51 https://youtrack 。 jetbrains.com/issue/KT-20034

此错误出现在旧设备(API 16)上。

通过删除 @Parcelize 注释并将其替换为以下代码生成器来修复此问题: https:/ /github.com/nekocode/android-parcelable-intellij-plugin-kotlin

In my case, this was a bug in kotlin plugin, version 1.1.51

https://youtrack.jetbrains.com/issue/KT-20034

This error appeared on old devices (API 16).

Fixed this by removing @Parcelize annotations and replacing them with this code generator: https://github.com/nekocode/android-parcelable-intellij-plugin-kotlin

诺曦 2024-10-26 20:30:22

targetSdkVersion 22//17============================>将此数字设置为小于或等于设备上 Android 操作系统的版本可能会有所帮助

 defaultConfig {
        applicationId "software.nhut.personalutilitiesforlife"
        minSdkVersion 16
        targetSdkVersion 22//17==========================> set this number less then or equal to the version of Android OS on devices might help
        versionCode 5
        versionName "1.26"
        // Enabling multidex support.
        multiDexEnabled true
    }

targetSdkVersion 22//17==========================> set this number less then or equal to the version of Android OS on devices might help

 defaultConfig {
        applicationId "software.nhut.personalutilitiesforlife"
        minSdkVersion 16
        targetSdkVersion 22//17==========================> set this number less then or equal to the version of Android OS on devices might help
        versionCode 5
        versionName "1.26"
        // Enabling multidex support.
        multiDexEnabled true
    }
白衬杉格子梦 2024-10-26 20:30:22

就我而言,问题发生在某些运行 API 21 和 22 的设备上。在 application 标记下的清单中设置 android:vmSafeMode="true" 解决了该问题。但是,不建议将其用于发布版本,因此我在 value 文件夹中创建了两个 xml 文件。较旧 API 的默认值:

<resources>
    <bool name="vm_safe_mode">true</bool>
</resources>

对于 API >= 23 且具有 false 值的情况也是如此。在这种情况下,具有较新操作系统的设备不会受到影响,而旧操作系统至少可以工作。

In my case problem was happening on some devices running API 21 and 22. Setting android:vmSafeMode="true" in manifest under application tag resolved the issue. However, it is not recommended for release builds, so I created two xml files in values folder. The default one for older API's:

<resources>
    <bool name="vm_safe_mode">true</bool>
</resources>

And the same for API's >= 23 with false value. In that case devices with newer OS won't be affected and the old ones will at least work.

彼岸花ソ最美的依靠 2024-10-26 20:30:22

当我的方法名称中有一些 Dalvik 不喜欢的 Unicode 字符(主要是因为从 powerpoint 文件复制/粘贴)时,我遇到了这个问题。您可以通过在尝试安装 APK 时查看 Logcat 输出来看到这一点。

这是在真实设备上进行的。

I had this problem when there were some Unicode characters in my method names (due to, of all things, copy/pasting from a powerpoint file) that Dalvik did not like. You can see this by looking at Logcat output while trying to install the APK.

This was on a real device.

且行且努力 2024-10-26 20:30:22

通过更正手机上的日期时间(默认日期 1980 年 1 月 1 日)并清理项目来解决。

Solved by correcting date time on the phone (it was some default date 01.01.1980), and cleaning the project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文