Eclipse: Conversion to Dalvik format failed with error 1 - android

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?

This doesn't look like the issue with proguard, since it's not even enabled in your defaults.properties file. Try the following:
Uncheck "Force error when external jars contain native libraries" option (just as you did)
Select "Project -> Clean…" from the menu
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):
michel's answer
user408841's answer
Mido's answer
Joe's Apps' answer

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.

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

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.

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.

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

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.

If none of the solutions work for you try to do the following:
Stop looking for online help.
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:
Create a new project.
In order to detect the suspicious class, begin adding your classes one by one every time running the export signed application tool.
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.

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 :)

Related

Delphi 11: Find correct toolsversion for MSBuild programmatically

We're upgrading to Delphi 11.1 from 10.4.
We have a few scripts which build and deploy Android projects. They assemble an msbuild command that looked like this:
msbuild someproject.dproj /v:q /p:Platform=Android /t:Build;Deploy /p:Config=Release /p:BT_BuildType=AppStore
With 11.1, this throws an error message:
C:\Program Files (x86)\Embarcadero\Studio\22.0\bin\CodeGear.Common.Targets(940,7): error MSB4036: The "XmlPeek" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Windows\Microsoft.NET\Framework\v2.0.50727" directory. [someproject.dproj]
Now, C:\Program Files (x86)\Embarcadero\Studio\22.0\bin\rsvars.bat, which is used by all of our build scripts, explicitly sets the .NET framework as below:
#SET FrameworkDir=C:\Windows\Microsoft.NET\Framework\v4.0.30319
#SET FrameworkVersion=v4.5
After some research, I hit on the idea of adding a toolsversion parameter to the msbuild command as below, and this worked:
msbuild someproject.dproj /v:q /p:Platform=Android /t:Build;Deploy /p:Config=Release /p:BT_BuildType=AppStore /toolsversion:4.0
This is all well and good, but I would prefer not to hard-code the toolsversion number in the script(s).
Is there a way I can programmatically obtain the correct value of the toolsversion that Delphi itself is using when it generates builds, etc.?
I assume that just finding the highest .NET version installed will not suffice (and even then, one has to "translate" that to a toolsversion). It has to marry up with whatever Delphi is doing (e.g., in the CodeGear.Common.Targets file referenced in the original error message).
This is a bug in Delphi 11.1 that has at least 3 bug reports: RSP-37855, RSP-38466, and RSP-38467.
You can add /tv:4.0 to your MSBuild command line, or modify the first line in the .dproj file to:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="Build">
Assuming that rsvars.bat has been run,
FOR %%v IN ("%frameworkdir%") DO SET "toolsversion=%%~nv"
ECHO msbuild ...blah... /toolsversion:%toolsversion:~1%
The variable frameworkdir will be set by rsvars.bat. The for command parses its value (eg. C:\Windows\Microsoft.NET\Framework\v4.0.30319 as though it is a filename, and picks v4.0 as the "filename" (~n modifier [filename] of the metavariable %%v)
Then use the value assigned to toolsversion, starting at character 1 (where the first character is "character 0")
--- Given more info in comment
FOR %%v IN ("%frameworkdir%") DO ECHO %%~nxv|FINDSTR /R ".*\..*\.">nul&IF ERRORLEVEL 1 (SET "toolsversion=%%~nxv") ELSE SET "toolsversion=%%~nv"
Oh ye of little faith :)

too many libraries when loading error, Chromium compile for Android4.2.2

I followed this to compile Chromium ( Actually I need content_shell_apk):
https://www.chromium.org/developers/how-tos/android-build-instructions
Compilation of both ChromePublic.APK and ContentShell.apk succefull, but when I run them in my Android 4.2.2 device, I get this error:
https://paste2.org/nxFYVvtW
Cannot load library: soinfo_alloc(linker.cpp:287): too many libraries when loading "libEGL_mali.so"
I am searching for 2 days, and only thing I could find is this:
comments.gmane.org/gmane.comp.web.chromium.devel/43328
How should I get rid of this error, and compile official ContentShell.apk for my device?
The issue is resolved. Somehow, my out/Default directory was corrupted.
I removed that directory, and run GN configuration again:
gn args out/Default
At this point, to make sure that there are no any debug symbols included:
target_os = "android"
target_cpu = "arm"
is_debug = false
is_component_build = false
is_clang = true
symbol_level = 1
After that, generated filesize for ContentShell.apk is around 40Mbytes ( Jan.2017 ), and it runs perfectly on Android 4.2.2 .
To be able to modify user interface, someone can edit shell_view.xml which is at:
./content/shell/android/java/res/layout/shell_view.xml
There are also a few java files, which can be edited easily, and make your own browser for your custom android device :)
Many thanks to people at #chromium for IRC help.

How to compile an AOSP project with my own custom bootanimation?

I'm trying to compile AOSP with a custom bootanimation, but with no success. And I just have run out of approaches... To change bootanimation, I've already done:
created a .zip file with the following structure:
bootanimation.zip {
desc.txt
part0 {
000.png, 001.png, ... ..., 010.png
}
part1 {
011.png, 012.png, ... ..., 021.png
}
}
edited permissions on system/core/include/private/android_filesystem_config.h
placed the bootanimation.zip file in /system/media/
However, when Android boots up, it just shows the Google trademark, skipping the boot animation. Can someone point what I'm missing?
PS: I'm successfully compiling AOSP. It boots up with all features ok. My problem is only with bootanimation customization on the compiled project.
Ok. I've solved my problem.
The issue was that besides all the things I've done, the bootanimation.zip file MUST be compressed with store method.
#mthama writes:
Ok. I've solved my problem. The issue was that besides all the things I've done, the bootanimation.zip file MUST be compressed with store method.
The solution is to not use any compression when packing the archive. This can be achieved on Linux with the following command:
zip -0r bootanimation.zip desc.txt part0 part1
The -0 option says to not use any compression and the -r option says to include contents of part0 and part1 recursively.
There are also ways doing this with a graphical interface, e.g. with 7-Zip as shown in this answer: https://superuser.com/a/337087/295453

How to generate javadocs for android project

I followed all the instruction given on stackflow, but unfortunately not able to generate doc file for my android project.
If I am not mentioning class path on last step of java doc generation, then getting "Android reference" error.
And if using it, then getting "javadoc: error - The -classpath option may be specified no more than once." error.
Using classpath:
-classpath "D:\Android 4.2 SDK\android_sdk\platforms\android-15\android.jar"
Am I using correct class path command ?
Please help me out.
Environment used:
Eclipse indigo
If you use Intellij IDEA go to Tools - Generate JavaDoc... Specify all the settings and set params: -bootclasspath [path]\android-sdk\platforms\android-{version}\android.jar -encoding UTF-8 -docencoding utf-8 -charset utf-8
More information is in this post.
Have You followed these steps (from www.mtholyoke.edu)? This works on my Project....if not and You get an error, please write here which error You get.
Project -> Generate Javadoc
In the "Javadoc command" field - browse to find javadoc.exe
• On the computers in the Clapp CS lab that is C:\JBuilderX\jdk1.4\bin\javadoc.exe
• On other computers it would be \bin\javadoc.exe
Check the box next to the project/package/file for which you are creating the javadoc
In the "Destination" field browse to find the desired destination (for example, the root directory of the current project).
Leave everything else as it is.
Click "Finish"
Javadoc should be in the destination folder. Open "index.html"
EDIT
I found a thread here in Stackoverflow with a lot of tipps, try this:
Javadoc in Eclipse failing to recognize packages
NEXT EDIT
It is only a possibility, but You specified Your classpath as:
"D:\Android 4.2 SDK\android_sdk\platforms\android-15\android.jar"
I know that eclipse got some problems with spaces inside a path. So the first part "Android 4.2 SDK" has to be specified without spaces, maybe here is the issue. But be aware, if You change this path, You have to set everywhere the new path where You have definded it.
I'm using the command line. I have also updated to Eclipse Kepler. It seems to execute javadoc differently? I'm investigating. But try this:
read the javadoc manual. It's confusing and doesn't tell you what to do, but, here's an example that should get you going.
Create a file called "options"
Add to the file this:
-d target-bin
-stylesheetfile style.css
-use
-splitindex
-windowtitle 'My Project Name Class Specification'
-doctitle 'My Project Name Class Specification'
-header '<b>My Project Name</b><br><font size="-1">0.1.5-alpha</font>'
-bottom 'Copyright 2014 My Company or Myself. All rights reserved.'
-group "Group Of Packages" "com.mypackage.*"
-overview overview.html
-exclude 'android'
-subpackages 'com.mypackage:android'
-charset utf-8
-encoding UTF8
-quiet
-sourcepath ../myProject/src;..\..\..\android-sdks\sources\android-19
Then on the command line type:
javadoc #options
Now, in Kepler, the "Generate Javadoc" dialog box says "What is the javadoc command line"...I suspect I'll have to type something like this. But don't know.
Hopefully this quick example will give you a start on how to get it done for your purposes.
By the way, I created a generic Eclipse project called "javadoc" in my Workspace so I could manage the files.

Tesseract-Android-Tools changes and modifications compiled successfully(i think) but no output

Currently I am trying to get tesseract android tools
http://code.google.com/p/tesseract-android-tools/
to work for me on Android. I have been going at this for about a week to no avail.
I am running Win 7 64 bit with cygwin.
I followed the instructions in the readme file and made many changes to the Android.mk files. Basically it was appending a slash to the path, so I had to manually hard code the paths of the individual files, or move to location of the files within the 3 packages to get it to build. However at the end of the build, I did not recieve a "Build Sucessful" notice, but the .so files were generated.
I ported it to eclipse as is and used the following code to get the extracted text.
private static final String TESSBASE_PATH = "/mnt/sdcard/";
Bitmap imageFile = BitmapFactory.decodeFile(image.getAbsolutePath());
TessBaseAPI baseApi = new TessBaseAPI();
if(baseApi.init(TESSBASE_PATH, "eng")){
System.out.println("Tessbase initialized");
baseApi.setDebug(true);
baseApi.setImage(bmp);
String recognizedText = baseApi.getUTF8Text();
System.out.println("---------------------output-------------------");
System.out.println("recognizedText<"+recognizedText+">");
}
else{
System.out.println("Tessbase initialization failure.");
}
At first I was getting an error saying
"Bitmap functions not available; library must be compiled under android-8 NDK"
After taking a look at the tessbaseapi.cpp file I realized that it needed a specific compiler flag to compile the correct function. This flag was -DHAS_JNIGRAPHICS. What I think this means is that the JNI Graphics library must be present.
Yet the program still wouldn't compile because the memcpy() function in the newly compiled method could not be found. I fixed this by changing the actual C++ code to include
Finally the program compiled fully (still wasn't getting a BUILD SUCCESSFUL notice though) and when I ran it, I did not get any output at all. This could be a problem with the eng.traineddata file, or could be a problem in the actual code.
Is there anything I have done wrong? Can someone link me to and eng.traineddata file that they know works and image that works with it?
Thanks in advance!
It's been a few months since you posted this question, however if you're still looking for answers I would seriously recommend that you have a look at the tess-two project on github.
Whilst this won't solve the error that you've posted, its a tactical work around/alternate solution.
It's a fork of tesseract-android-tools and is incredibly easy to use, you'll have it up and running within the hour.
If you're getting poor results, make sure that traineddata file is there, use DDMS file explorer to check its there and not 0 bytes (that happened to me a few times).
Also, make sure you set the whitelist and blacklist characters, this will improve results very well.
Good luck

Categories

Resources