Skip to content Skip to sidebar Skip to footer

Error When Calling Pure Java Code (separate Project) From Android In Eclipse

I have this simple java code: package com.androiddesktoptest.testtest; public class AndroidDesktopTestMain { public static void main(String[] args) { callFromAndro

Solution 1:

Order & Export isn't the most well built feature of the Android ADT.

If you instead include the linked src folder from the Desktop project to your Android project (Right Click Project > Build Path > Link Source Folder) then the Class will be used as if it belongs to the Android Project.

I think the prefered way of doing this would be to create a jar file or a Library Project but these might be too cumbersome to try until you have stable Deskptop code.

Hope that helps!

Solution 2:

Sounds like you don't get the class over to the phone when u run your android.

Make sure that:

right click project - properties - java build path - Order and Export (is it checked here?)

Solution 3:

This article about including Java libraries into Android projects suggests replacing the "JRE System Library" with the android.jar for your API level in your linked Java project's build path dialog.

Solution 4:

try this

new AndroidDesktopTestMain.callFromAndroid();

The only way to call a non-static method from a static method is to have an instance of the class containing the non-static method. By definition, a non-static method is one that is called ON an instance of some class, whereas a static method belongs to the class itself.

Post a Comment for "Error When Calling Pure Java Code (separate Project) From Android In Eclipse"