So I have noticed fairly recently a folder within my Phonegap/Android project (project/bin/dexedLibs) and this folder contains two .jar files. After scratching around the internet, I found one website in which the author says ADT version 21 puts "pre-dexed Libs" in the project to enable faster build times.
I did upgrade recently to ADT 21 and was just wondering if anybody else can give me more information on what these "pre-dexed Libs" really do? I haven't been able to find any other useful info on the net.
I have an Android project with about 20 external libraries. Before ADT 21, every time I changed source code it took ages to rebuild the app. Now it's quite fast!
I guess the reason is that, before ADT 21, it compiled the external libraries into dex code every time you hit the "Run" button in eclipse. Now it will compile the dex code for the external libraries only once (until they change) and use the prebuild libraries for later "Run"s.
I like that feature!
Be aware! I've just spent an hour to find out why I get the exception:
Caused by: java.lang.NoSuchMethodError:
The reason was because I changed my lib jar to new jar (the same name) with working method, and ADT 21 didn't prepare the new one in dexedLibs.
So just delete bin dir and Eclipse will recreate this.
The question is about 2 years old yet still of interest.
For people who browse here later: I just had trouble because I renamed a Cordova project from my.name.a3e to my.name.A3E and then the build process crashed. Came out that the dexed files in ant-build were not refreshed (case sensitivity). It worked fine after I deleted the ant-build folder, but the build took longer the first time after.
A dex file is a Dalvik EXecutable file, some compiled byte code that can be executed by the Dalvik virtual machine. Dalvik is a core component of Android, so that's why it is there.
http://sourceforge.net/projects/dexer/
http://developer.android.com/reference/dalvik/system/DexFile.html
http://fileinfo.com/extension/dex
Note that Eclipse project clean won't remove dexed libs.
Related
Using Eclipse, is possible to generate an Android project using multidex for creating multiple
dex files? Searching over the net I found how to do that using gradle but nothing about to use that on
Eclipse without gradle
It looks like ADT's ant-tasks project is no longer maintained (it resides under 'legacy' folder).
So if you can't migrate to Gradle, you can edit the DexExecTask manually. You'll have of course to rebuild the project locally..
[Edit - 10/25/2014] maven-android-plugin does support multi-dex. However, it currently has a small issue: secondary dex files placed in wrong location. This pull request strives to fix that, so stay tuned! (Fixed in 4.0.0)
I am studying Look API (from Samsung Mobile SDK). To do this I have put sample from Samsung Mobile SDK to my app. There is nothing complex, just Activity is created and a texview from one of Look classes is instintiated.
When I run the app on a simulator (open smartclip activity) I got error from dalvikvm. From LogCat:
Could not find class 'com.samsung.android.sdk.look.smartclip.SlookSmartClip$1', referenced from method com.samsung.android.sdk.look.smartclip.SlookSmartClip.setDataExtractionListener
I use ADT bundle with Mobile SDK 1.0.2 (Look is 1.0.0).
Simulator device is Android 4.2.2 without Look support (but it does not matter as all files exported).
I verified that the project configured correctly to export the look.jar into resulting apk-file.
I have checked that all the external libraries are exproted to apk and have de-dexed the resulting classes.dex to verify that class SlookSmartClip$1 is actually there.
Maybe this question is more general to ADT 22 + 3rd party jar library problem. But almost always people do not export the files propertly, here I do not have this issue.
Do you know what is the problem?
PS: I tried to unchecked Android Private Library in export. After that the libraries are not appear in bin/dexedLibs and not in apk (classes.dex). After checking again (cleaning project all the time), they appear in bin/dedexedLibs and packaged into apk in classes.dex. I do not understand how dalvikvm cannot find them...
This error is generated only when library is not well included you need to add the lib jar provided by samsung to the project
right click project-> properties -> java build path -> libraries.
and add your jar
When I right click on a project on Eclipse and click on "Run as Android App", does it have a different build process then Ant builds?
Currently I am working on an app that uses another project as a library dependence. Everything compiles fine and the app loads, but when I try to use the functionality the library provides, problems come up. The library has a checksum file to verify that the library resources are loaded correctly. When I build to my phone from Eclipse, this check passes. But when I use my ant build, the resource check fails.
I have compared both apk results (diff -rq ant/ eclipse/) and my differences are as follows:
Files ant/AndroidManifest.xml and eclipse/AndroidManifest.xml differ (this is expected)
Files ant/META-INF/CERT.RSA and eclipse/META-INF/CERT.RSA differ
Files ant/META-INF/CERT.SF and eclipse/META-INF/CERT.SF differ
Files ant/META-INF/MANIFEST.MF and eclipse/META-INF/MANIFEST.MF differ
Files ant/classes.dex and eclipse/classes.dex differ
Files ant/resources.arsc and eclipse/resources.arsc differ
I suspect resources.arsc may be causing the problem. The size of these files are only 8 bytes different.
I'm lost on this, anyone have an idea of why this is happening. I've tried deleting the checksum file, but the library won't work without it.
Every time I add a library to my Android project the compilation process gets slower. Is there a way to cache the (library) dex files so only the application gets recompiled every time? Ideally the build process should check whether the library JAR has changed, if it hasn't it should reuse the prexisting dex file.
I am using nbandroid but I assume the Eclipse build suffers from the same problem.
The Build process (especially at dex step) in Android SDK (regardless of which IDE is in used) is quite inflexible. The only command usage of dx.jar AFAIK is something like below:
[INFO] C:\Program Files\Java\jdk1.6.0_21\jre\bin\java -Xmx1024M, -jar, C:\Program Files\Android\android-sdk\platform-tools\lib\dx.jar, --dex, --output=C:\workspace\myproject\target\classes.dex, C:\workspace\myproject\target\classes, C:\workspace\myproject\libs\common-lib.jar, ... ...
From here you can see that compiled classes with external jar libraries are dexed at project build time.
Is there a way to cache the (library) dex files so only the application gets recompiled every time?
Jar libraries get dexed, not recompiled by Android SDK every time you build your project. I don't think Android SDK provide another command usage of dx.jar which you can use to dex only the complied class without external jar libraries then merged into the pre-existing classes.dex (perhaps generated from last time).
It is not possible at project build time, however, it is probably off topic but you may interested in this blog talked about dynamically loading jar libraries at runtime, worth to check it out.
I'm using Eclipse and have a few projects with 2-3MB of libraries, did not notice any slowdown except when compiling and signing final APK with proguard. Looks like Eclipse does not recompile libraries every time.
I've got a shared object, which I'll call 'libFoo.so', compiled against the NDK. I have a java project (I'll call it 'jarlib') that makes use of that shared object, by calling
System.loadLibrary("Foo");
That java project, I export as a jar, and use in an android application. If I comment out all the bits about the shared object, the jar works fine, and I'm able to interact with it perfectly.
I can use jarlib, along with the shared object from a Unity android application with the shared object in ./lib/armeabi/libFoo.so, and it loads it up all peachy.
I'm trying to use the jarlib and libFoo.so in my non-unity android app, and loadLibrary absolutely refuses to find the libFoo.so. I've tried placing it so it will be included in my apk in ./lib, as well as ./lib/armeabi, and nothing seems to make the load call see it.
I've tried including the libFoo.so in ./lib or ./lib/armeabi of the jarlib, but once I try to build/run my android app, I'm told:
The library 'jarlib.jar' contains native libraries that will not run on the device.
The following libraries were found:
- libFoo.so
with this, if it's in the ./lib (not ./lib/armeabi)
Additionally some of those libraries will interfer with the installation of the application because of their location in lib/
lib/ is reserved for NDK libraries.
I'm not sure what combination I'm missing, but I'm sure it can be done, I just can't seem to figure out how to do it!
Well! It turns out it was something so tiny, that it caused me eight hours of headaches.
I found that my libFoo.so wasn't showing up in my app.apk/lib/armeabi/libFoo.so like it did when unity built the apks. I assumed it had something to do with that, so I started looking for settings to make sure that my lib folder was copied to the apk.
As it turns out, the lib folder is not, however...
Remember how I said I tried it in (on the android application side):
./lib/libFoo.so
-and-
./lib/armeabi/libFoo.so
Turns out, what I needed to do was put it in a similar path. Oh so similar.
./libs/armeabi/libFoo.so
Yeah. libs. With a s.
In fact, when I renamed my folder 'lib' to 'libs', it changed the icon of the folder in eclipse to have the little android symbol on it, like the bin or res folders have. And sure enough, when you build the apk, the lib/armeabi folder is there (notice it's named 'lib' in the apk, and not 'libs'. This still confuses me.)
One of my co-workers (that was working on this project before me) told me that somewhere along the line, the folder used to be 'lib', but was then changed to 'libs' in a later version of the android SDK. Either way, having just picked up this project, I didn't realize that the folder should have been named 'lib', as it seemed fine to me. I was about ready to pull my hair out. I'm leaving this here in the hopes that SOMEONE has the same problem I did, and manages to solve it a bit faster.