Create JAR from Eclipse Project - android

I'm trying to build this project https://github.com/OnlyInAmerica/Osmdroid-Plus/wiki to a JAR but I can't. I followed the "Configuration" steps in there and alredy have the Tomcat ant command to build, but it says "build.xml does not exist!" and ant -v command doesn't work either or creating a build with eclipse. I export it as jar with eclipse but using that JAR gives me an error in my project "Conversion to Dalvik format failed with error 1".

have you try this? :
Right click on project -> export -> select under "java" -> select path -> finish
this step would create a jar file for your project.
to use the jar into another project:
Right click on your project -> Build Path -> Add external archive -> select the jar file

Related

Android Studio: Importing Eclipse project from SVN along with Library projects

I am able to import the main project along with two other library projects from SVN. But while in the process if I select,
"Create project from existing sources" it creates the project and after doing some modifications in Project settings it works. But I could not find the Gradle file and it gives error "The project 'CrossConnectRefactored' is not a Gradle-based project" if I select the Gradle icon.
If I select "Import project from external model -> Gradle", it creates the project but still without 'Gradle' file and it gives the similar error.
If I first Export the project from Eclipse using 'Android -> Generate Gradle build files' and import the same in AndroidStudio then it creates all the required Gradle files properly. But I didn't get option to build/run the project and it always says 'Gradle project sync failed. Basic function...'.
It also gives the below error,
Could anyone please help me out with the 1st or 2nd option?

Importing gradle project to eclipse

I have problem with importing this library into eclipse. Things I did:
run gradlew.bat (inside project) that downloaded and installed it
run CMD
set my SDK with command "set ANDROID_HOME=C:\dev\android-sdk-windows"
run command gradlew build
after successful build image I tried to import project into my eclipse but it's incomplete (without any classes)
It's first time I'm using gradlew, could you tell me what I'm doing wrong?
This library is built with Android Studio or Intellj.
These steps with Gradle are referred to Android Studio or IntellJ.
I don't know this lib, but if you are using Eclipse, you should do:
clone a copy of this repository, or download it (outside eclipse workspace)
import the code in your workspace starting from library/Donation-lib folder
mark java(*) folder as source (click on folder -> Build-Path -> use as source folder). You can also remove the src folder, from the project.
mark aidl(*) folder as source
add support library v4 rel.XX ( click -> Android Tools -> Add support library , or just copy android-support-v4.jar in libs folder)
mark your project as Android Library (Properties -> Android -> Is library)
(*) Eclipse uses src and res as source folders.
Android Studio instead uses src/main/java , src/main/res and src/main/aidl as source folders.
Open file build.gradle and add this line on top:
apply plugin: 'eclipse'
In project directory invoke command
gradlew.bat eclipse
Open project in Eclipse (import) like normal eclipse project
More info: Eclipse Plugin
Alternatively use dedicated Eclipse plugin Gradle Integration for Eclipse 3.4.0.RELEASE
There is a simplest and quick way to import a Gradle project into Eclipse. Just download the Gradle plugin for Eclipse from here.
https://marketplace.eclipse.org/content/gradle-integration-eclipse-0
And then from import select Gradle and your project would be imported. Then you have to click on Build Model to run it.
EDIT
Above link for Gradle plugin is no more valid. You can use the following link.
https://marketplace.eclipse.org/content/buildship-gradle-integration

how to export android code

there.
I noticed that samples on Google developers page can be imported on "Existing Android Code Into Workspace" menu on eclipse, not "Existing Projects into Workspace". I wonder how I can export my project as android code like the samples. I tried to find out that feature on eclipse but failed. Can you tell me how to do it please? And what is good to export as android code not existing projects?
by this step in your ADT,you will get your project as a Zip file.
Right-click, Export -> General, Archive File -> Next -> provide the output path -> Finish.
to get as a apk then try this step
Export -> Android -> Export Android Application ->
YOUR_PROJECT_NAME ->
Create new key store path -> Fill the detail -> Set the .apk location -> Now you can get your .apk file
You need to export to apk file. Refer here : here and also here

create a jar file - Dalvik error

I have an android project that contains only a .java file. This java file extends the class Services.
I am trying to build a jar file using * *Build Fat JAR**.
I did the following:
right click the project -> select Fat Jar and inside the Configure Fat Jar Plug-In I've selected the OPTION: select Manifest file. With next-> finish I've managed to create the .far file.
PROBLEMS:
The jar icon has a red x mark in front of it. When adding the jar inside another project and when running the application (creating apk) I get the following:
Dx trouble writing output: invalid header field. Conversion to Dalvik format failed with error 3
What am I doing wrong?
Need some help.
Thank yiu
To Create a JAR from a Android project follow below steps
Project -> Properties -> Android -> Check 'Is Library' option.
Now build Project and get jar in 'bin' folder.

Generate Ant buildfiles error

Im trying to generate ant buildfiles.But Im receiving a error
"The build class path order of the source directories of project library is not correct. Exported Ant buildfile will not compile your sources correctly until you swap the order of these directories:
gen<->src"
Im building from eclipse using file->export->Ant-buildfile
When im trying to build from command-line i recieve:
$ ant debug
Buildfile: /build.xml
BUILD FAILED
Target "debug" does not exist in the project "com.Grupp01.gymapp.MainActivity".
Screen capture of error and eclipse:
I had the same probem. Solving was: right click on library ->Properties ->Java Build Path -> Order and Export. Entry "gen" must be upper then "src" (use buttons up, down).
I have dolved this using this steps.
Right Click on your project -> Properties -> Java Build Path-> "gen" should be upper than "src". So, re arrage the folders. It worked for me.

Categories

Resources