Java 没有在路径上找到类:dexpathlist

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23074381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 20:28:31  来源:igfitidea点击:

Didn't find class on path: dexpathlist

javaandroideclipsemavenbuildpath

提问by VulfCompressor

Seriously, i don't know what to do to solve this problem. My android project was working fine, until i needed to import a library with Maven. Since that, everything started to collapse.

说真的,我不知道该怎么做才能解决这个问题。我的 android 项目运行良好,直到我需要使用 Maven 导入一个库。从那以后,一切都开始崩溃了。

What is happening: When i start my application, the following error appears on LogCat and android tells that my app stopped working. I've searched for this similar error here AND on the rest of the internet, but everything people did haven't worked for me.

发生了什么:当我启动我的应用程序时,LogCat 上出现以下错误,android 告诉我我的应用程序停止工作。我在这里和互联网的其他地方搜索过类似的错误,但人们所做的一切都对我不起作用。

Error:

错误:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.buscaserra/com.buscaserra.main.ActivitySplash}: java.lang.ClassNotFoundException: Didn't find class "com.buscaserra.main.ActivitySplash" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.buscaserra-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.buscaserra-2, /vendor/lib, /system/lib]]

java.lang.RuntimeException:无法实例化活动 ComponentInfo{com.example.buscaserra/com.buscaserra.main.ActivitySplash}:java.lang.ClassNotFoundException:在路径上找不到类“com.buscaserra.main.ActivitySplash”: DexPathList[[zip 文件“/system/framework/com.google.android.maps.jar”, zip 文件“/data/app/com.example.buscaserra-2.apk”],nativeLibraryDirectories=[/data/app- lib/com.example.buscaserra-2, /vendor/lib, /system/lib]]

Manifest and packages: manifestpackages

清单和包: 显现包裹

Build Path: buildpath

构建路径: 构建路径

Please, i don't know what else to do. My project deadline is near and im desperate. Thanks in advance.

拜托了,我不知道还能做什么。我的项目截止日期快到了,我很绝望。提前致谢。

采纳答案by Federico

Same problem here. What worked for me was adding android-support-v4.jar as a lib and making sure it was checked on Project properties -> Build Path -> Order & export. It was mentioned here

同样的问题在这里。对我有用的是将 android-support-v4.jar 添加为 lib 并确保在项目属性 -> 构建路径 -> 订单和导出上检查它。这里提到

回答by code4cause

Do you have any required projects on the build path? Can't tell from your screen shot but check your "Projects" tab. You may have inadvertently added a Project Library as a required project instead. Remove the project from the Projects tab and then project -> properties. Click Android, add the project as a library instead here...

您在构建路径上是否有任何必需的项目?无法从您的屏幕截图中看出,但请检查您的“项目”选项卡。您可能无意中将项目库添加​​为必需项目。从项目选项卡中删除项目,然后项目 -> 属性。单击Android,将项目添加为库,而不是在这里...

回答by JDJ

Make sure that any compatibility lib jars that you're using in your main project (like android-support-v4.jar) are the same versions as those used in any of the projects that your main project references.

确保您在主项目中使用的任何兼容性库 jar(如 android-support-v4.jar)与您的主项目引用的任何项目中使用的版本相同。

I had this same problem and what solved it was to copy and paste the android-support-v4.jar from another library project (that my main project was referencing) and pasting it into my main project's /libs folder.

我遇到了同样的问题,解决它的方法是从另一个库项目(我的主项目正在引用)复制并粘贴 android-support-v4.jar 并将其粘贴到我的主项目的 /libs 文件夹中。

回答by Khanh Hua

I had the same problem when I moved the project folder from a Linux machine to a Mac.

当我将项目文件夹从 Linux 机器移动到 Mac 时,我遇到了同样的问题。

What I did was:

我所做的是:

  1. Close the project
  2. Remove the .iml file
  3. Import the project using the "Create new project using existing code"
  1. 关闭项目
  2. 删除 .iml 文件
  3. 使用“使用现有代码创建新项目”导入项目

I am using IntelliJ.

我正在使用 IntelliJ。

Cheers.

干杯。

回答by Angel Koh

I did the following steps to resolve the issue on Android Studio.

我执行了以下步骤来解决 Android Studio 上的问题。

  • open file ./app/build.gradle
  • reduce compileSdkVersion (e.g. 22 -> 21)
  • click 'sync project with gradle file'
  • change back to the original compileSdkVersion (e.g. 22)
  • click 'sync project with gradle file'
  • 打开文件 ./app/build.gradle
  • 减少 compileSdkVersion(例如 22 -> 21)
  • 单击“将项目与 gradle 文件同步”
  • 改回原来的compileSdkVersion(例如22)
  • 单击“将项目与 gradle 文件同步”

recompile and it should work.

重新编译它应该可以工作。

回答by Akash Bisariya

I should understand the problem by just seeing "dex errors".But it took half day to fix the issue. I fix this by following android developers page's instruction: https://developer.android.com/studio/build/multidex.html

我应该通过看到“dex错误”来理解问题。但是解决问题花了半天时间。我按照android开发人员页面的说明解决了这个问题:https: //developer.android.com/studio/build/multidex.html

First add this to my gradle.build:

首先将其添加到我的 gradle.build 中:

defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...

// Enabling multidex support.
multiDexEnabled true
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

Then I extend my Application class (or declare the application class in AndroidManifest.xml or override attachBaseContext() function) as instructed by the MultiDexApplication class document on the page. This have fixed my problem.

然后我按照页面上 MultiDexApplication 类文档的指示扩展我的应用程序类(或在 AndroidManifest.xml 中声明应用程序类或覆盖 attachBaseContext() 函数)。这解决了我的问题。

回答by Oldman Winter

I had the same issue. Nothing had changed except Android studio and Gradle updated since I last compiled.

我遇到过同样的问题。自从我上次编译以来,除了 Android studio 和 Gradle 更新外,没有任何变化。

I took a look at the build options under Build>Edit Build Types and noticed that the one option that was different between my project that didn't run and the ones that did work was the Minify Enable option.

我查看了 Build>Edit Build Types 下的 build 选项,并注意到我的项目没有运行和有效的项目之间不同的一个选项是 Minify Enable 选项。

I set it to false and now everything works again.

我将它设置为 false,现在一切又正常了。

回答by Derek Medina

I have spent way to many hours on this stupid issue but finally got it resolved:

我在这个愚蠢的问题上花了很多时间,但最终得到了解决:

When creating a new project -> package name is causing this stupid dex issue to appear, must not be able to find the main activity during run time with whatever deployment assemply setup. Android Studio doesn't like some of my commonly used package names, I'm completely baffled..I think this is a pretty big bug haha

当创建一个新项目时 -> 包名导致这个愚蠢的 dex 问题出现,在运行时一定不能找到主要活动,无论是什么部署组件设置。Android Studio 不喜欢我常用的一些包名,我完全莫名其妙..我觉得这是一个相当大的bug 哈哈

Given the following new project parameters:

给定以下新项目参数:

Name: NotificationApp, packageName: com.stores.business.notificationapp, saveLocation: /home/me/AndroidStudioProjects/NotificationApp

名称:NotificationApp,包名称:com.stores.business.notificationapp,saveLocation:/home/me/AndroidStudioProjects/NotificationApp

I would get the following error:java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.stores.business.notificationapp/com.stores.business.notificationapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.stores.business.notificationapp.MainActivity" on path: DexPathList[[zip file "/data/app/com.stores.business.notificationapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.cvs.stores.myapplication-2/lib/arm64, /vendor/lib64, /system/lib64]] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)

我会收到以下错误:java.lang.RuntimeException:无法实例化活动 ComponentInfo{com.stores.business.notificationapp/com.stores.business.notificationapp.MainActivity}:java.lang.ClassNotFoundException:找不到类“ com.stores.business.notificationapp.MainActivity" 在路径上:DexPathList[[zip 文件 "/data/app/com.stores.business.notificationapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com. cvs.stores.myapplication-2/lib/arm64, /vendor/lib64, /system/lib64]] 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)

My SolutionI resolved it by changing the package name to:com.notificationapp, then File->invalidate caches/Restart..hope this helps someone else haha

我的解决方案我通过将包名更改为:com.notificationapp,然后文件-> 使缓存无效/重新启动来解决它。希望这对其他人有帮助哈哈