I'm trying to import a jar named Security.jar into an Android app that I'm currently working on, however, no matter what I do I cannot get AS to recognize the package that I'm importing. I pasted the jar into the libs folder that I created for the app and synced the gradle files, as well as modified the dependancies, all to no avail. If anyone sees ANYTHING that's wrong please let me know! Here's a link to some pictures pertaining to the issue.
http://imgur.com/a/sEoXi
error log build.gradle
I believe that you should do this:
compile files('libs/your.api.jar')
When you've pasted the jar file in the libs folder. Give it a shot.
A good way to add external JARs to your Android project or any Java project is:
right click on your project ..
then goto properties..
then click on java build path..
then click on libraries...
then click on add External JARs..
select jar file ..
click on ok
Related
Ok, this is going to be a really stupid question but I can't figure out a solution. So I added a .jar file to Android Studio the following way:
exported .jar file using IntelliJ IDEA
copied .jar to libs folder under app folder in the Project view in Android Studio
Right clicked the .jar and selected "Add as Library"
The line compile files('libs/MyJar.jar') was added to the build.gradle file. However I cannot figure out how to actually use the classes in the jar. I can't seem to import it at all, and it is as if I didn't actually add anything. What am I doing wrong?
I know this is an idiotic question, but I can't find a solution.
If you've added the jar as you say and if gradle builds successfully after adding the jar then you can just start coding in your Activity you'll get an prompt to import the associated class file in your .jar.
I am still receiving errors due to jsoup in eclipse. I have dropped the JAR in the project's tab, rightclick the JAR file and then chose Build Path > Add to Build Path but it still does not work.
http://imgur.com/SCqLxWN
Could you please help me?
#Thank you for responses!
I have done as you advised me but it still does not work.
http://imgur.com/Y5B9Em2
I am just a beginner but when I am using other packages everything works, I have troubles only with this jsoup. Do you have any other ideas?
Create a folder named libs in the root of your project and put your jar files here. Then go to project Properties, under Java Build Path > Libraries click on Add JARs... and select you jar file, under the libs folder.
Try to remove the following code as your class is inside the default package.
package org.jsoup.examples;
I set a lookAndFeel synthetica theme for the project.After that it is not working(jar file in the dist).
Again I removed it and tried.Then it worked. I did clean and build.
Tried several themes. They all workedd in the project. But did not run in the dist.
What should I do? Please help me..
I have experienced this before in my projects. Most of the time it happen because of using icons and images.
When /Icons/calculator.png image in your package, it is not wrong in netbeans like this getClass().getResource("/Icons/Calculator.png").
this is working on netbeans. but not in jar file. you need to rename Calculator.png.
use jar file in console (CMD in windows , shell in linux) with this command
java -jar adress-jar-file/jarfileName.jar
then see error in console.
Just Right click on yoru projet in netbeans and select Set Configuration then Customize in the window that appears provide your Main Class by clicking the browse button or writing it manually and Clean and Built again
Plz make sure some points.
1) You have set main class properly.
Right click on Project-> project properties-> Run-> set Main-Class
2) You have set theme path properly.
3) Your themes are not corrupted.
4) You have build your jar properly.
Right click on project-> clean and build(Note: Do nothing while it finish building jar)
5) Your lib folder not corrupted (if it is present).
It looks like there maybe something wrong with your setup. In your project properties, under libraries have you by chance added synthetica.jar as a required jar. but m not sure try it
but you can simply do,
you could create lib folder manually in your project folder and then paste that jar in that folder then through netbeans go to your project then right click on libraries and then browse to find your project folder open that then click on lib folder that you have created open it then click on jar that you have pasted and that jar file will be added to your project.
I could resolve my problem.I'm sorry that I was used trial version Synthetica.jar. after I bought it and done every thing from the beginning. I resolved it. Thank you for your contribution to resolve it.thank you
I am using Parse.com and I upgraded the parse SDK from 1.2.4 to 1.3.0. I have deleted the 1.2.4 files from the libs folder and pasted the 1.3.0 files to libs folder. When I am trying to run my app now it is crashing with no error. After debugging I found out that when I try to open any declaration of Parse class files it shows me this:
Here is the build path screenshot:
I have tried to clean the project, closed and opened eclipse.
I am stucked! Any help would be appreciated
Please verify the BuildPath as well.
Right Click on the Project -> BuildPath -> Configure Build Path
Check to see there is .jar files or not. If there are no .jar files, Upload using "Add Jars" button from your libs directory. Once Build Path is configured, clean and run the Project. Hope this will help you.
From your figure you posted, it just that your editor cannot find source for your jar file. But in your figure i do see javadoc. In the same page you will see a button called "Attach source". You can click that button to locate manually your javadoc. With this you should be able to go to source code.
I found the solution, but it was not related to the libs file or to the build path. The problem was in the manifast, had to remove android:noHistory="true" from my activity tag and the every thing worked fine.
I have downloaded a messaging framework library from eneter.net. In eclipse I have imported the library to the /libs folder. I right clicked on the library and then added it to the build path. I know that the code is right, but when I compile it and try to run it, it says that that it can't find the classes. Odd thing is when I open up the apk in a zipping program, the library wasn't added to the apk at compile time. Does anyone know why this would be?
Try right-clicking your project in Eclipse's project explorer, then hit Properties. Go to the tab labeled Java Build Path and hit Add Library... (or if it is a jar file, Add JARs... if you already added the Jar to your project and Add External JARs... if it is not yet within the project). From there, browse for the library you wish to add and add it to the project. Re-compile (maybe even Project->Clean) and try running it, and see if the library gets added now.
I right clicked on the library and then added it to the build path
That is not necessary, as of the R17 version of the ADT plugin in Eclipse. Moreover, it may cause problems if you do it.
Does anyone know why this would be?
Possibly because there is a typo in your directory name, such that it is not named libs/. By adding it manually to your build path, you are compiling against it, but the build tools are not adding it to the APK.
Is the library in the form of a complete Android project? This is then used with another Android project by going to the Properties of that project, selecting the Android tab, and then finding and selecting that library in the lower window.