How to reference a java project in my android project? - java

I am making an android app. I have created a java project also that uses BufferedImage to manipulate images. I want to use this project in my android project. How can I do that?
I'm using eclipse. When I right click my android project > properties > android > [add]
my java project isn't in the available options. I think I need to somehow mark it as library.
Does anyone know how I can do this?
Thanks

Add your Java project to your build path:
Right click on your Android project, click on Properties. In the dialog, select Java Build Path, and then click on the Projects tab. There, add your Java project to the build path.

make JAR of your BufferedImage project and then copy it inside your new project, then right click on the JAR in Eclipse and Choose Build Path -> Add to classpath or something like that

Related

How can I run the Alloy model checker API in Eclipse?

I am having trouble importing Alloy libraries to use the API in Eclipse. This is the code I am trying to run: http://alloytools.org/documentation/code/ExampleUsingTheAPI.java.html
The problem is that I am doing something wrong importing the libraries. So this is what I did:
Create a new Java Project (JRE: jdk1.8.0_172) in Eclipse
Right Click in the project > Import > Archive File > select the .jar file org.alloytools.alloy.dist.jar downloaded from https://alloytools.org/download.html
All folders and files are added as in the next picture below.
Create new file in scr folder: ExampleUsingTheAPI.java, with the code from http://alloytools.org/documentation/code/ExampleUsingTheAPI.java.html
The errors displayed are:
Download the jar, right click on your project, select configure build path, click on libraries and add external jar, select your Alloy api and click apply and ok.
If i'm not wrong it should work, i used to do the same when using eclipse.

Eclipse ADT appcompat... what is it?

I've spent all afternoon getting absolutely nowhere with this.
I've downloaded Eclipse, downloaded the SDK, installed the updates, but every new Android project I create something's wrong.
Firstly, it would not generate the R.java file, at all, now it does but there's a separate project it's created automatically called appcompat_v7. I don't know what this is, but it's causing problems with any other new project.
This is the error a normal project produces:
The container 'Android Dependencies' references non existing library '/home/omar/workspace/appcompat_v7/bin/appcompat_v7.jar'
I have absolutely no idea how to fix this. What is causing this?
EDIT
It appear this is only with KitKat, every other API platform doesn't produce ANY source files at all.... any idea how to combat this?
It's a support library which presumably your project refers to. You will need to build it as a library project in your workspace. This process is described here Support Library Setup under Adding libraries with resources.
You will find the project you need to copy in your SDK in the folder:
\yourSDKlocation\tools\android-sdk-windows4.4\extras\android\support\v7\appcompat
(It's no use just copying a jar, you must build it as a library project.)
I had this problem when I moved a project to a different laptop. I solved it like this:
If appcompat_v7 is not available in Eclipse:
From the File menu, choose New then Project.
Next, choose Android and Android Project from existing Code, then click next
Browse to find your appcompat_v7 project folder
Make sure there’s a check mark next it in the ‘Projects to Import’ list
If the appcompat_v7 project folder is not currently in your workspace, select ‘Copy projects into workspace’, then click Finish
Now that the library project is available in your workspace, it can be added to a project:
Choose your project from the Project Explorer and open the project properties (on a mac it’s in the Project menu)
Click on Android in the left list
Next to the Library list, click the Add button
Choose appcompat_v7 from the list
You should be good to go now.

Box2dLights on libGDX android project

I tried to import the jars of Box2dLights to my project in libgdx, I configure the Buildpath and errors always happen.
Where I need to put the jars? Someone know please?
thanks : )
Right-click into your core libGDX project, Build Path > Configure Built Path...
Select the Libraries tab, Add JARs... and choose box2dlights.jar you've downloaded. Then on the same tab select it and click on the Source attachment. Click on Edit... and browse your box2dlights-sources.jar
//important part
Now, right-click on your libGDX android project, Build Path > Configure Built Path... and do the same as later, but choose your box2dlights.jar located in your core project.
Go on Order and Export tab, check your box2dlights.jar, and move it up, below your gdx-backend-android.jar
still trying to improve my english,
Hope it works!
It doesn't matter.
Put the Jar in the libs's folder of your android project
When you configure the Buildpath, in the Order and export, don't forget to check the box2dlights.jar
By the way, if you still got errors, you should tell us what are them.

In Android project include another project

I'm just starting my long way to Android programming and building app where I would like to use this library https://github.com/cfgxy/DevsmartLib-Android/tree/
This is another Android project, how should I include this in my project using Eclipse?
The contents of that repo's devsmartlib/ directory appears to be an Android library project. You can use such projects from Eclipse or from the command line as you see fit.
Create a new Android project in Eclipse and select the contents of devsmartlib/ as the source folder.
You can then right click on your project, click Properties, Android and add the library project from there!

"could not find com_facebook_android.apk error" when running Android project

I've installed the Facebook API for Android in Eclipse, and imported the project into my Android project. My program builds perfectly fine, but when I try to run it I get
Could not find com_facebook_android.apk!
in the build window, and when the program actually tries to import any of the Facebook API classes it blows up with a java.lang.NoClassDefFoundError: com.facebook.android.Facebook
Probably you added the reference to the Java project in the "Java Build Path" but it's the wrong place.
From the Android guide:
To add a reference to a library project, follow these steps:
In the Package Explorer, right-click the dependent project and select Properties.
In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
Click Add to open the Project Selection dialog.
From the list of available library projects, select a project and click OK.
When the dialog closes, click Apply in the Properties window.
Click OK to close the Properties window
This resolved my problem.
Check out referencing libraries instructions here:
http://developer.android.com/guide/developing/projects/projects-eclipse.html
Make sure you have the latest versions of ADT.
Try to clean your project in eclipse.
Hope this helps
In my case helped, not to have in the referenced projects checked Is Library
(Project Properties > Android)
I am also having issues with this error and have noted that if I run eclipse as root then the error disappears. This makes me think it is a permissions issue
So to help:
On the com Facebook android project right click > android tool > build and export
Then simply build the project into the bin folder of the Facebook project.
Problem solved
I had a similar problem. This was my resolution. I had to add android.jar as a reference.
Android samples error
If nothing works, try deleting the Facebook application for Android (if you have one installed on your phone). This worked for me.

Categories