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

Dynamic class loading vs injection
Populate attribute in List of Objects in Java using Lambda
Asynchronous service with Spring boot
No protocol malformed URL Exception thrown at me when trying to parse an XML String
Read 3 selected item in the same time
how to use setter and getter in different functions?
Unable to download file from Google Drive using Java API
Sending and reading a 2D array using sockets Java
/Date(long + 1000)/ format
possible paths to the top of a staircase
What is the best way to implement search in Android?
What is <?> in java? [duplicate]
XML file in a Linux environment not showing the correct symbol
Hibernate Migration from 3 to 4 SerializableBlob Class Deprecated
Is possible to access net.tcp service(WCF) through java client? [closed]
ElasticSearch Capacity Requirement for productions

Categories

HOME
yii2
openmp
oracle11g
activiti
gremlin
fluentd
appx
jira
elm
graphql
v8
cloudkit
php-7.1
netflix
workload-scheduler
beyondcompare
swingx
autoconf
jndi
crosstab
greendao
opentype
subdomains
kendo-datasource
srcset
calibre
textmate
ghost4j
html5-fullscreen
file-format
simplexml
lto
squib
node-gyp
outlook-api
reactive-cocoa-5
appcompat
hendrix
fancybox-2
pg-dump
media-player
orthogonal
mediaelement
pintos
messenger
android-fonts
angular-cache
mongocsharpdriver
fputcsv
ubuntu-10.04
bgp
dlna
design-by-contract
two-factor-authentication
uid
intellij-14
content-length
dukescript
drawbitmap
tableau-online
method-parameters
generic-programming
geonetwork
relocation
codeigniter-routing
client-side-templating
device-manager
websocket4net
issuu
xojo
mesa
braille
google-cloud-save
sabredav
limejs
chuck
gdata-api
newtonscript
tridion-worldserver
wse3.0
reddot
code-cleanup
external-accessory
genshi
jmock
fluent-interface
coda-slider
multi-tier
nintendo-ds
phonon
mediarss
msdev
caching-application-block

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App