Java Question Library problem

HotShoe

Well-Known Member
Licensed User
Longtime User
I have created 2 libraries for b4a. The first is a string library that mimics C and Pascal libs I have used for years. This lib works fine.

The second is a file handling lib that adds common Linux functions that I need in a new file manager project. Things such as reading and setting file permissions, moving and renaming files, things that are not in the b4a File class.

The file handling lib has no errors in generating the javadoc, and the .jar exports fine. My test project in b4a sees the new lib (yes I refresh each time I change the lib in eclipse and re-copy the files), and the project compiles without error in b4a.

The problem is that b4a shows an error in the logs on the Dim statement. In the unfiltered logs, I see that the method I call for the lib is not found. Also there is no classes.dex file in the objects dir of the project.

Why is the lib not being included in the project? I am using jdk 7 and both eclipse, and b4a are using jdk 7 as well. The paths are correct, and everything compiles and plays nice, except no classes.dex in being generated.

I'm confused...

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
All of the methods appear in the b4a project along with their descriptions and code completion. So, it is seeing the xml file just fine, but it is not including the jar file itself (or so it seems).

Thanks,

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Sorry, I used 7zip to create it. I have replaced it with a standard .zip file at the same link.

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
That seems to have fixed the problem. Shame I was really hoping to use those nice nio2 methods in jdk 7. Is there a way to get to the java packages included in the android.jar? I can't seem to access specific classes in there, I always get the class from the on disk jdk.

Thanks,

--- Jem
 

warwound

Expert
Licensed User
Longtime User
Is there a way to get to the java packages included in the android.jar? I can't seem to access specific classes in there, I always get the class from the on disk jdk.

Have you added android.jar to your library's build path?

http://www.b4x.com/forum/libraries-...eating-libraries-basic4android.html#post39444

Creating a new project:
1. Create a new Java project (not Android project).
2. Add a reference to the following jars: android.jar, B4AShared.jar and optionally to Core.jar.
This is done by right clicking on the project name - Build Path - Add External Jars.

android.jar is part of the Android SDK.
By default you should choose the android.jar that is located under <android-folder>\platforms\android-4.

If you want to use Android API classes from more recent API versions obviously you'll need to choose the corresponding platform folder.

Martin.
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Yes I have, but the android.jar has a full java implementation in it as well. There are some android specific things in its java.* that it would be nice to get to, but I don't see how because the class names are the same.

--- Jem
 

warwound

Expert
Licensed User
Longtime User
I'd remove existing import statements from your project that relate to the classes you want to use and wait a moment until eclipse highlights the missing classes in your code.

Then go through the errrors - hover a while on each one and the popup that appears with auto-correct suggestions should offer to import the native java class OR the android class.

Martin.
 

CharlesIPTI

Active Member
Licensed User
Longtime User
Java Version

Android uses Java 6. Make sure that you target Java 6 and not 7 (you can use Java 7 JDK but should set the target version to 6).


This is an old post but is this still true ?

How do you set the target version in Basic4Android
 
Top