9

This happens instantly when I make a new project in 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.

I have updated ProGuard (I think), downloaded the new version, and replaced the lib folder as the threads on here said.

My default.properties file looks like this:

# 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. I feel I have tried everything, and still this bug. One thing I have noticed though if I go to: window -> preferences -> android -> build. And uncheck "Force error when external jars contain native libraries". Then I get: "Can't resolve R" instead of the Dalvik error.

There is no import named android.R either.

Anyone with some help please?

Volo
  • 28,673
  • 12
  • 97
  • 125
Anders Metnik
  • 6,096
  • 7
  • 40
  • 79

9 Answers9

19

This doesn't look like the issue with proguard, since it's not even enabled in your defaults.properties file. Try the following:

  1. Uncheck "Force error when external jars contain native libraries" option (just as you did)
  2. Select "Project -> Clean…" from the menu
  3. If that won't help ensure you have the correct R class imported. As stated at 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. This will cause your make to break. Look out for these erroneous import statements and delete them.

UPDATE

Have a look also at this thread: "Conversion to Dalvik format failed with error 1" on external JAR.
Check the following answers (link will bring you directly to the answer):

Community
  • 1
  • 1
Volo
  • 28,673
  • 12
  • 97
  • 125
  • Afraid not, cleaned with android.R imported, same errors, removed it again. Now reports dalvik thingy again. :-( Reinstall? – Anders Metnik Sep 27 '11 at 07:48
  • @AndersMetnik Reinstall. If that won't help, could you share your skeleton project somewhere (maybe on file hosting packed in the zip)? So I can have a look at it and test it on my environment. – Volo Sep 27 '11 at 10:06
  • @AndersMetnik Did you succeed? If no - check my updated answer. – Volo Oct 04 '11 at 10:07
  • Reinstalled and did something else aswell, it helped, sorry i forgot to update the question with how, and have forgotton now :-/ – Anders Metnik Nov 09 '11 at 14:51
5

I had mistakenly added a reference to a copy of android.jar, which was not required as it is an android dependency, I removed this and the error went away.

John
  • 51
  • 1
  • 1
2

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.

After that everything started working again. This is apparently a logged bug... http://code.google.com/p/android/issues/detail?id=18359

Justin
  • 6,564
  • 6
  • 37
  • 34
1

Do you have the new Android SDK? If you do, you have to download the proguard.jar from the proguard website and replace it on the SDK directory.

neteinstein
  • 17,529
  • 11
  • 93
  • 123
0

You have to clean your project every time if you use CVS update.

Jake
  • 1,195
  • 6
  • 21
  • 42
0

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.

darrenp
  • 4,265
  • 2
  • 26
  • 22
0

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.

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. 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.

l gr
  • 1
0

I've tried many solutions on stackoverflow but nothing worked for me. 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

I just removed one line and this worked for me :)

Sahar Malik
  • 895
  • 1
  • 6
  • 4
0

I just was fighting with this problem myself what I ended up doing is editing the proguard.bat file and the problem vanished

it's in: [Android SDK Installation Directory]\tools\proguard\bin\proguard.bat

Change

call %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

I tried tons of other stuff but this is what did it for me.

Kit Ramos
  • 1,533
  • 1
  • 15
  • 32