简体   繁体   English

Eclipse:转换为Dalvik格式失败,错误1

[英]Eclipse: Conversion to Dalvik format failed with error 1

This happens instantly when I make a new project in Eclipse. 当我在Eclipse中创建一个新项目时,会立即发生这种情况。

I only have 1 jar file in the project, I have tried to remove it, and add it again, several times, and cleaned the project after this. 我在项目中只有1个jar文件,我试图将其删除,然后重复添加几次,并在此之后清理项目。

I have updated ProGuard (I think), downloaded the new version, and replaced the lib folder as the threads on here said. 我更新了ProGuard(我认为),下载了新版本,并将lib文件夹替换为此处的线程说。

My default.properties file looks like this: 我的default.properties文件如下所示:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-8

So can't comment anything about ProGuard which was also mentioned in another thread. 因此无法评论ProGuard的任何内容,这也是另一个线程中提到的。 I feel I have tried everything, and still this bug. 我觉得我已经尝试了一切,但仍然存在这个错误。 One thing I have noticed though if I go to: window -> preferences -> android -> build . 我注意到的一件事,如果我去: window -> preferences -> android -> build And uncheck "Force error when external jars contain native libraries" . 并取消选中“当外部jar包含本机库时强制错误” Then I get: "Can't resolve R" instead of the Dalvik error. 然后我得到: “无法解决R”而不是Dalvik错误。

There is no import named android.R either. 没有名为android.R导入。

Anyone with some help please? 有人帮忙吗?

This doesn't look like the issue with proguard, since it's not even enabled in your defaults.properties file. 这看起来不像proguard的问题,因为它甚至没有在defaults.properties文件中启用。 Try the following: 请尝试以下方法:

  1. Uncheck "Force error when external jars contain native libraries" option (just as you did) 取消选中“当外部jar包含本机库时强制错误”选项(就像您一样)
  2. Select "Project -> Clean…" from the menu 从菜单中选择“项目 - >清洁...”
  3. If that won't help ensure you have the correct R class imported. 如果这无助于确保您导入了正确的R类。 As stated at source.android.com : source.android.com所述

    Eclipse sometimes likes to add an import android.R statement at the top of your files that use resources, especially when you ask eclipse to sort or otherwise manage imports. Eclipse有时喜欢在使用资源的文件顶部添加导入android.R语句,尤其是当您要求eclipse对排序或以其他方式管理导入时。 This will cause your make to break. 这会导致你的品牌破产。 Look out for these erroneous import statements and delete them. 注意这些错误的import语句并删除它们。

UPDATE UPDATE

Have a look also at this thread: "Conversion to Dalvik format failed with error 1" on external JAR . 另请参阅此主题: “在外部JAR上转换为Dalvik格式失败,错误1”
Check the following answers (link will bring you directly to the answer): 检查以下答案(链接将直接带您回答):

我错误地添加了对android.jar副本的引用,这不是必需的,因为它是一个android依赖项,我删除了这个并且错误消失了。

I started having this problem as well... The only thing that fixed it for me was manually downlaoding the newest version of ProGuard (currently 4.6) and replacing the SDK's version of Proguard's bin and lib folders with the newest verison. 我也开始遇到这个问题......唯一能解决这个问题的是手动下载最新版本的ProGuard(目前为4.6)并用最新版本替换SDK版本的Proguard bin和lib文件夹。

After that everything started working again. 之后一切都开始了。 This is apparently a logged bug... http://code.google.com/p/android/issues/detail?id=18359 这显然是一个记录错误... http://code.google.com/p/android/issues/detail?id=18359

Do you have the new Android SDK? 你有新的Android SDK吗? If you do, you have to download the proguard.jar from the proguard website and replace it on the SDK directory. 如果您这样做,则必须从proguard网站下载proguard.jar并将其替换为SDK目录。

如果使用CVS更新,则每次都必须清理项目。

I have had this problem occasionally and the fix for me is to switch off 'Build Automatically'. 我偶尔会遇到这个问题,对我来说修复是关闭'自动构建'。 In my experience, Eclipse sometimes gets confused when building apks when automatic building is switched on. 根据我的经验,当打开自动构建时,Eclipse在构建apks时有时会感到困惑。

If none of the solutions work for you try to do the following: 如果没有一个解决方案适合您,请尝试执行以下操作:

  1. Stop looking for online help. 停止寻找在线帮助。
  2. Turn to your project. 转向您的项目。 It can be something in the code that Dalvik interprets in wrong way even if there are no reported errors during the run of application. 即使在应用程序运行期间没有报告错误,Dalvik也会以错误的方式解释代码中的某些内容。

I had such a problem. 我有这样的问题。 Multiple runs/builds/exports of application with Proguard disabled were successful and only after enabling Proguard an error 1 appeared. 禁用Proguard的应用程序的多次运行/构建/导出是成功的,只有在启用Proguard后才会出现错误1。 Following steps can help you to resolve the problem: 以下步骤可以帮助您解决问题:

  1. Create a new project. 创建一个新项目。
  2. In order to detect the suspicious class, begin adding your classes one by one every time running the export signed application tool. 为了检测可疑类,每次运行导出签名的应用程序工具时,都要逐个添加类。
  3. Narrow the search in that class by adding blocks of code to it also one by one. 通过逐个添加代码块来缩小该类中的搜索范围。

In my case the error was caused by: 在我的情况下错误是由以下原因引起的:

float[][] array1 = null, array2;
for(int i = 0; i < someVal; i++){
    if(array1 == null){
        array1 = new float[row][col];
    }
    else{
        array2 = new float[array1.length][array1[0].length]; // ERROR 1
        // it was assumed that array1 is still null
    }
}

When I replaced it with: 当我用它替换它时:

float[][] array1 = new float[1][1], array2;
for(int i = 0; i < someVal; i++){
    if(i == 0){
        array1 = new float[row][col];
    }
    else{
        array2 = new float[array1.length][array1[0].length]; // ERROR 1
        // it was assumed that array1 is still null
    }
}

the ERROR 1 disappeared. ERROR 1消失了。

I've tried many solutions on stackoverflow but nothing worked for me. 我在stackoverflow上尝试了很多解决方案,但没有任何方法可以帮助我。 I just open the project.properties file in project folder and appcompat library was added twice here like android.library.reference.1=../appcompat_v7 android.library.reference.1=../appcompat_v7 我只是在项目文件夹中打开project.properties文件,appcompat库在这里添加了两次,如android.library.reference.1 = .. / appcompat_v7 android.library.reference.1 = .. / appcompat_v7

I just removed one line and this worked for me :) 我刚删除了一行,这对我有用:)

I just was fighting with this problem myself what I ended up doing is editing the proguard.bat file and the problem vanished 我自己就是在解决这个问题,我最后做的是编辑proguard.bat文件,问题就消失了

it's in: [Android SDK Installation Directory]\\tools\\proguard\\bin\\proguard.bat 它位于:[Android SDK安装目录] \\ tools \\ proguard \\ bin \\ proguard.bat

Change 更改

call %java_exe% -jar "%PROGUARD_HOME%"\\lib\\proguard.jar %* 调用%java_exe%-jar“%PROGUARD_HOME%”\\ lib \\ proguard.jar%*

to

call %java_exe% -jar "%PROGUARD_HOME%"\\lib\\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9 调用%java_exe%-jar“%PROGUARD_HOME%”\\ lib \\ proguard.jar%1%2%3%4%5%6%7%8%9

I tried tons of other stuff but this is what did it for me. 我尝试了很多其他的东西,但这就是为我做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM