I am writing a simple Bluetooth 4.0 application which base on Samsung series mobile phone. Android is going to support Bluetooth 4.0 but it does not happen so far. That means I still need using Samsung BLE SDK to use Bluetooth 4.0, that's ok.
When I started learning Samsung BLE SDK via attached samples, it works well. It is build-able under Eclipse, it works. When I used Ant to build the apk (yes, I used to use command-line tool to do developing.), it failed.
I got a run-time error: <A Class> had used a different <B class>; during pre-verification
W/dalvikvm(22070): Class resolved by unexpected DEX: Lcom/samsung/ble/pxpmonitor/ProximityService$3;(0x430e85d0):0x40086000 ref [Lcom/samsung/android/sdk/bt/gatt/BluetoothGattCallback;] Lcom/samsung/android/sdk/bt/gatt/BluetoothGattCallback;(0x430e85d0):0x40038000 W/dalvikvm(22070): (Lcom/samsung/ble/pxpmonitor/ProximityService$3; had used a different Lcom/samsung/android/sdk/bt/gatt/BluetoothGattCallback; during pre-verification) W/dalvikvm(22070): Unable to resolve superclass of Lcom/samsung/ble/pxpmonitor/ProximityService$3; (60) W/dalvikvm(22070): Link of class 'Lcom/samsung/ble/pxpmonitor/ProximityService$3;' failed D/AndroidRuntime(22070): Shutting down VM W/dalvikvm(22070): threadid=1: thread exiting with uncaught exception (group=0x41f83930) E/AndroidRuntime(22070): FATAL EXCEPTION: main E/AndroidRuntime(22070): java.lang.NoClassDefFoundError: com/samsung/ble/pxpmonitor/ProximityService$3 E/AndroidRuntime(22070): at com.samsung.ble.pxpmonitor.ProximityService.(ProximityService.java:195) E/AndroidRuntime(22070): at java.lang.Class.newInstanceImpl(Native Method) .....(skip) E/AndroidRuntime(22070): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
Because the apk file I built contains ble_sdk.jar, and Samsung Galaxy S4 has the same (at least, the same name) implementation under /system/framework.
The problem is that I have to build some classes which depend on ble_sdk.jar, but I cannot package the ble_sdk.jar into apk file since it makes duplication.
In general, we put dependency libraries to directory libs, but the dex-helper macro in Android Ant build system merges EVERY JAR FILES INTO classes.dex. Cool, that bites me.
To put the ble_sdk.jar outside directory libs and asks ant-building-system refer to it? it doesn't work, we even cannot override the property jar.libs.dir. (issue #33194)
I tried to figure it out but quit with no luck. If you know a good way match my requirement, please tell me. This is my workaround. (workaround means --- Someday I will bite myself.)
Workaround: Do not package each jar under libs unless I ask you to do that.
Add a custom_rules.xml to your project with these statements.
<project> <target name="-post-compile"> <path id="project.all.jars.path"> <!-- un-comment below line if you want it--> <!-- <pathelement path="libs/please_package_this.jar"> --> </path> <echo level="info">To be packaged jar: ${toString:project.all.jars.path} </project>
It cleans project.all.jars.path that defines Android ant-building-system's merge targets. I don't like this idea but it basically works.
If you are using "android update project ..." to establish your ant build environment, you may consider to specify the command line option as
ReplyDeleteant -Djava.compiler.classpath=${path-of-the-jar-file} ...
This just triggers the compile time validation without including the jar into the apk.
This comment has been removed by the author.
ReplyDeleteInspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information.
ReplyDeleterpa training in chennai | best rpa training in chennai | rpa training institute in chennai | rpa courses in chennai | rpa training in pune | rpa online training | rpa training in bangalore
Thank you for an additional great post. Exactly where else could anybody get that kind of facts in this kind of a ideal way of writing? I have a presentation next week, and I’m around the appear for this kind of data.
ReplyDeleteData Science Training in Chennai | Data Science training in anna nagar
Data Science training in chennai | Data science training in Bangalore
Data Science training in marathahalli | Data Science training in btm
Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..
ReplyDeletejava training in omr | oracle training in chennai
java training in annanagar | java training in chennai
I'm here representing the visitors and readers of your own website say many thanks for many remarkable
ReplyDeletepython training Course in chennai
python training in Bangalore
Python training institute in kalyan nagar
Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.
ReplyDeleteBest Devops Training in pune
it is vey nice and usefull guide. I alllways fallowe your tips and i inspried with your work and knowedge.if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.https://www.udtapaisa.com/mutual-funds
ReplyDeleteThank you for sharing information it is very helpful
ReplyDeleteTablet Repairing Course in Laxmi Nagar
This is extremely fascinating substance! I have completely delighted in perusing your focuses and have reached the conclusion that you are right about a hefty portion of them. You are extraordinary. cursos de ti online
ReplyDeleteMy partner and I stumbled over here by a different website and thought I should check things
ReplyDeleteout. I lke what I see so now i am following you.thanks a lot guys.
C and C++ Training Institute in chennai | C and C++ Training Institute in anna nagar | C and C++ Training Institute in omr | C and C++ Training Institute in porur | C and C++ Training Institute in tambaram | C and C++ Training Institute in velachery
it was very much useful for me and because of your blog, and also I gained many unknown information.
ReplyDeletePython Training in Chennai
Python Training in Bangalore
Python Training in Hyderabad
Python Training in Coimbatore
Python Training
python online training
python flask training
python flask online training
thanks you for sharing best knowledge free fire diamond
ReplyDeleteSummertime Saga Benzeri Oyunlar
ReplyDeleteAmong Us Benzeri Oyunlar
Valorant Benzeri Oyunlar
Rust Benzeri Oyunlar
Fortnite Benzeri Oyunlar
6K4M