I want to import a class that I made in Eclipse to a project in Android Studio. I have been working on a project in Eclipse which involves a custom class called WordList
and I have serialized an instance of this class into a binary file.
Now, I have just started to learn about android programming and I wanted to make an app that uses this file. I want to use something like this to read the WordList
object from that file:
ObjectInputStream in = new ObjectInputStream(
new FileInputStream(new File( /*file name*/ )));
return (WordList) in.readObject();
But in order to do that, the program of course needs to know about the WordList
class, otherwise I'll get a ClassNotFoundException
at the cast. What I did first was to create a new WordList
class in the Android project that was just an exact copy of the one in the Eclipse project, but then I got that exception:
java.lang.ClassNotFoundException: Didn't find class "package_name.WordList" on path: DexPathList[[zip file "/data/app/my_project_directory-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
.
So apparently, these two identical WordList
classes are in fact not identical. Why is it so? Is there a way for me to import the class from the Eclipse project into the Android Studio project, so that I actually can use the very same class? Or is there a way to make the program realize that the file actually contains a serialized WordList
object?