2011年3月29日 星期二

Unable to execute dex: Java heap space

最近要用到第三方的庫android-sdk-windows\platforms\android-8\data\layoutlib.jar,但出現Conversion to Dalvik format failed: Unable to execute dex: null這個問題。且出現對話方塊

下面是解法:
(註: 紅色標記表示有試過但不行,綠色標記表示有試過可行。)

As Android developer, I have met a strange problem when I want use a third party jar, it remained me that:   
Dex Loader] Unable to execute dex: null   
Conversion to Dalvik format failed: Unable to execute dex: null   
out of memory error…An internal error occurred during: “Build Project”.   
Java heap space   
  
This is the DEX Error,I find the solutions by Google, one way is to modify the eclipse.ini, you can increase the memory allocated in eclipse.ini to this: -Xms128m -Xmx512m or something higher, but this didn’t work for me. After modify the eclipse.ini, I cannot start the eclipse. By StackOverflow, I find a solution:   
  
eclipse.ini file must have -vm on first line and path on second line. don’t try to put everything into one line!   
-vm   
C:\Program Files\Java\jdk1.6.0_07\bin\javaw.exe   
  
After add the -vm and the path in my eclipse.ini, I can start my Eclipse and the problem has been resolved.   
  
Another way to solve the ” Conversion to Dalvik format failed: Unable to execute dex: null” problem is using the user library, the concrete steps are as follows:   
1. Right-click the project in Eclipse and select “Build Path -> Add Libraries…”.   
2. Select User Library from the list and click Next.   
3. Click the “User Libraries…” button.   
4. Click “New…” in the User Libraries dialog.   
5. Give the user library a name and select the System library checkbox and click OK.   
6. Highlight the newly added user library in the list and click the “Add JARs…” button and add the desired jar files.   
7. Click OK on the User Libraries dialog.   
8. Make sure the new user library is checked in the Add Library dialog and …   
  
Posted by CuteAndroid  

沒有留言: