java


Android Bluetooth deserialization ObjectNotFoundException


Well I have some trouble to deserialize my class over bluetooth. From pc to android device im Using the bluecove snapshot 2.1.1 library on my pc application My inputstream on android does receive bytes because as soon I send some data to my ouputstream my android application crash.
So here my stack trace. Also, the bluetooth socket is working since I can send integers into bytes on the pc
W/System.err: java.lang.ClassNotFoundException: bluetooth.LiteProject
W/System.err: at java.lang.Class.classForName(Native Method)
W/System.err: at java.lang.Class.forName(Class.java:324)
W/System.err: at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:2258)
W/System.err: at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1641)
W/System.err: at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:657)
W/System.err: at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1782)
W/System.err: at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:761)
W/System.err: at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983)
W/System.err: at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940)
W/System.err: at com.example.ihat3i.androidtesting.BluetoothThreadClasses.BluetoothDataShare.deserialize(BluetoothDataShare.java:121)
W/System.err: at com.example.ihat3i.androidtesting.MainActivity.onClick(MainActivity.java:96)
W/System.err: at android.view.View.performClick(View.java:5714)
W/System.err: at android.widget.TextView.performClick(TextView.java:10926)
W/System.err: at android.view.View$PerformClick.run(View.java:22589)
W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err: at android.os.Looper.loop(Looper.java:148)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7325)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "bluetooth.LiteProject" on path: DexPathList[[dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-support-annotations-25.0.0_733f073c18693e37682f4ac22b5f541d6f65a521-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_9bc67552422813c99b6458ea8770395016890bfd-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_5030af852f549789ae15eb264dc11320e23256e8-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_4a2c66133c72c8cb335db37fa043de6026539626-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_3a303aa6f7e828e43c1336863ca83eefc55642dc-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_2d05349ce99bb610027ae1a1f205e7ff481c80ea-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-vector-drawable-25.0.0_93d794c274330c4bac9e23b24b0692ce4a48b160-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-v4-25.0.0_bf3767cfe44655d3a165ffe94a66d5d9feaa2a26-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-media-compat-25.0.0_8edae4c59f3b3f76c9b225952262e5bc47b157df-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-fragment-25.0.0_f7d3af020703d4b4bd21e04d132251937de287d4-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-core-utils-25.0.0_86f6e8f7e9b82e3cd1e20da88591291ea705ca15-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-core-ui-25.0.0_6d54f4432204da9a7699fadec1a26048490d7085-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-compat-25.0.0_95ad1fee5438892c0a020310eab8df2a9dced983-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-appcompat-v7-25.0.0_44eb0fc3008faa9171481a9770d2142ed7ee8ee5-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-25.0.0_788179e51b8915f8f95cd660c0d2ba6af7650941-classes.dex"],nativeLibraryDirectories=[/data/app/com.example.ihat3i.androidtesting-1/lib/arm, /vendor/lib, /system/lib]]
W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err: at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
W/System.err: ... 21 more
W/System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "bluetooth.LiteProject" on path: DexPathList[[zip file "/data/app/com.example.ihat3i.androidtesting-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.ihat3i.androidtesting-1/lib/arm, /vendor/lib, /system/lib]]
W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
W/System.err: ... 22 more
W/System.err: Suppressed: java.lang.ClassNotFoundException: Didn't find class "bluetooth.LiteProject" on path: DexPathList[[dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-support-annotations-25.0.0_733f073c18693e37682f4ac22b5f541d6f65a521-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_9bc67552422813c99b6458ea8770395016890bfd-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_5030af852f549789ae15eb264dc11320e23256e8-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_4a2c66133c72c8cb335db37fa043de6026539626-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_3a303aa6f7e828e43c1336863ca83eefc55642dc-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-internal_impl-25.0.0_2d05349ce99bb610027ae1a1f205e7ff481c80ea-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-vector-drawable-25.0.0_93d794c274330c4bac9e23b24b0692ce4a48b160-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-v4-25.0.0_bf3767cfe44655d3a165ffe94a66d5d9feaa2a26-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-media-compat-25.0.0_8edae4c59f3b3f76c9b225952262e5bc47b157df-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-fragment-25.0.0_f7d3af020703d4b4bd21e04d132251937de287d4-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-core-utils-25.0.0_86f6e8f7e9b82e3cd1e20da88591291ea705ca15-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-core-ui-25.0.0_6d54f4432204da9a7699fadec1a26048490d7085-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-support-compat-25.0.0_95ad1fee5438892c0a020310eab8df2a9dced983-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-appcompat-v7-25.0.0_44eb0fc3008faa9171481a9770d2142ed7ee8ee5-classes.dex", dex file "/data/data/com.example.ihat3i.androidtesting/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-25.0.0_788179e51b8915f8f95cd660c0d2ba6af7650941-classes.dex"],nativeLibraryDirectories=[/data/app/com.example.ihat3i.androidtesting-1/lib/arm, /vendor/lib, /system/lib]]
W/System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err: at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
W/System.err: at com.android.tools.fd.runtime.IncrementalClassLoader.findClass(IncrementalClassLoader.java:62)
W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
W/System.err: ... 23 more
W/System.err: Suppressed: java.lang.ClassNotFoundException: bluetooth.LiteProject
W/System.err: at java.lang.Class.classForName(Native Method)
W/System.err: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
W/System.err: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
W/System.err: ... 24 more
W/System.err: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
here in my code from android where I receive the Object and deserialize it
public class BluetoothDataShare extends Thread {
private final BluetoothSocket mmSocket;
private static InputStream mmInStream;
private static OutputStream mmOutStream ;
public static LiteProject lite = null;
public BluetoothDataShare(BluetoothSocket socket) {
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
// Get the input and output streams, using temp objects because
// member streams are final
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) {
Log.e(TAG, "temp sockets not created");
}
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
public static LiteProject deserialize() {
ObjectInputStream o = null;
LiteProject liteProject = null;
try {
o = new ObjectInputStream(mmInStream);
} catch (IOException e) {
e.printStackTrace();
}
try {
liteProject = (LiteProject) o.readObject();
o.close();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return liteProject;
}
/* Call this from the main activity to send data to the remote device */
public void write(byte[] bytes) {
try {
mmOutStream.write(bytes);
} catch (IOException e) { }
}
/* Call this from the main activity to shutdown the connection */
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
Log.e(TAG, "close of connect socket failed");
}
}
}
this is the code where I serialize on the pc
public static byte[] serialize(LiteProject liteProject){
ByteArrayOutputStream b = new ByteArrayOutputStream();
try(ObjectOutputStream o = new ObjectOutputStream(b)){
o.writeObject(liteProject);
}catch(IOException ex ){}
return b.toByteArray();
}
this is where the outputStream is initialized
private StreamConnection mConnection;
// Constant that indicate command from devices
private static final int EXIT_CMD = -1;
private static final int SWIPE_RIGHT = 1;
private static final int SWIPE_LEFT = 2;
public static OutputStream outputStream;
public ProcessConnectionThread(StreamConnection connection)
{
mConnection = connection;
}
#Override
public void run() {
try {
// prepare to receive data
InputStream inputStream = mConnection.openInputStream();
outputStream = mConnection.openOutputStream();
System.out.println("waiting for input");
while (true) {
int command = inputStream.read();
if (command == EXIT_CMD)
{
System.out.println("finish process");
break;
}
processCommand(command);
}
} catch (Exception e) {
e.printStackTrace();
}
}
this is where the outputstream send the serialized object to the android device
if(isSelected()){
OutputStream outputStream = ProcessConnectionThread.outputStream;
if(outputStream != null){
Project project = projects.get(selectedIndex());
LiteProject liteProject = new LiteProject(project);
outputStream.write(ProjectMethods.serialize());
And finally this is the LiteProject class that are the same on both side (pc and android)
public class LiteProject implements Serializable {
private static final long serialVersionUID = 2L;
private int slideCount;
private String[] notes;
private int[] animationsCount;
private String name;
public LiteProject(Project project){
slideCount = project.getSlideCount();
notes = project.notes;
name = project.getName();
}
public String getName(){return name;}
help !

Related Links

last character not rotating correctly
Java: showInputDialog and ProcessBuilder
Concurrent read access on map structure without lock
Java Swing - Working with Threads
Using an IF statement based on a random event
JavaFX nullpointer exception when using new nodes
Why is Java's TargetDataLine.read() so slow?
Saving frequently used apps to shared preferences
Java 8: Type inference fails when mapping objects to method references [duplicate]
How to use onNewIntent() in AppCompatActivity?
Navigate back to the respective Fragment using up button
What is the purpose of #InitBinder's value element?
JTextField Data Validation
Can not Connect to MLab Mongo Database from mongodb java driver
I can't move my JLabel with Key Binding?
Error while running maven project via Jenkins

Categories

HOME
pandas
twitter
minimum-spanning-tree
session
relayjs
routes
rsync
amortized-analysis
gps
webpack-2
in-app-purchase
awesome-wm
wheelnav.js
floating-action-button
nstableview
jplayer
iolanguage
evopdf
oracle-coherence
code-review
swingx
bootstrap-tour
zurb-foundation-6
lcd
icloud-api
numerical-methods
spark-jobserver
kannel
minitab
publish
replaceall
primitive
madlib
ecto
xquery-3.0
stringtemplate
language-concepts
mpmediaquery
angularjs-factory
azure-ml
preconditions
android-tabhost
reportingservices-2005
nand2tetris
nxlog
babel-core
cubic-spline
hibernate-tools
boost-multi-index
lowpass-filter
csound
snmptrapd
flutterwave
spring-cache
orthogonal
account-kit
background-service
specrun
grails-tomcat-plugin
sts-springsourcetoolsuite
asp.net-4.5
etsy
prettytensor
master-slave
dlna
bluemix-app-scan
tform
freedesktop.org
qtableview
pundit
ionic
microbenchmark
ami
system32
remobjects
streambase
truevault
c++03
google-style-guide
android-imagebutton
relocation
mdt
cctv
qcodo
preferences
wp-query
htmlcleaner
doskey
undefined-reference
didselectrowatindexpath
openlaszlo
ora-00911
eclipse-memory-analyzer
rabl
pushbackinputstream
pygit2
clipper
rdoc
wse3.0
gwt-ext
tomcat-valve
horizontal-accordion
self-extracting
netbeans-7.1
calling-convention
jmock
telerik-scheduler
gacutil
data-acquisition
document-conversion

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App