I'm currently trying to use open source JMRTD in an Android project where it can read Machine Readable Travel Document (MRTD) standards. Based on what I read so far, gradle can support maven artifact and so I need to defined jmrtd as a dependency. It make me a little relieved.
Second, it is a must to use combo jmrtd + scuba in this project?
One of my friend suggest to me to use jmrtd + scuba ant file which floating around. But it not sound a good idea and solution to me. There also some discussion state that (**I forgot what are the link is), there are some issues with the dependency on Scuba and JMRTD where in maven repo produced by ant build system file actually contains duplicates of every class. And gradle will not allow it and will cause build failure.
So back to main question:
How to use JMRTD in Android Studio where build system is Gradle?
And what is the element or library should I use together?
I am nowhere to find the implementation and tutorial of jrmtd in gradle.
Related
(I asked a similar question earlier, so I'll try a more general form and see if anybody knows how to do that.) There's a Java library to which I have added patches for Android support. I would like to automate testing of the code, but in order to check if it runs properly on Android, I need to test it on Android. The library artifact is a jar, though, not an AAR or an APK, so I don't want to remove the old build modes, and so far my attempts to add the Gradle Android Plugin yields errors like The 'java' plugin has been applied, but it is not compatible with the Android plugins.
How can I continue to produce a plain Java jar, but also automatically test it on Android? Do I need to, like, make a new submodule or something specifically for the tests?
Yes, usually it's a good practice to create a new module, say integration-tests, which in itself is an android library/app, and then you'd include your JAR/java lib in there and run android tests over it.
So I took a Coursera course that had me work with external libraries. Two .jar files which most of the weekly projects depended upon.
I'm not entirely sure how eclipse compiles and runs the files, and how it links to these external libraries -- what is the proper way of organizing this? Do I put a copy of each .jar file in each project directory?
Is there another, cleaner way that I should be organizing this?
Thanks --
As a beginner programmer it is OK to put it in each project. But consider that this is ongoing work and at some time in future you want to upgrade to a new version of these external libraries. Then you would have to copy it everywhere.
Instead another option is to store them in one place and add it in classpath in each project. Now you have only one copy of it, which is always better.
Now, if and when you do get a new version then the file names might change, so you will still have to change the classpath of each project.
But I advise you to worry about these and other such problems later. For now, focus on programming related problems rather than configuration.
If you want to maintain your libraries professionally in a formal manor then you're better of using a build tool like Gradle of Maven.
I'd suggest you to use Gradle to maintain the project since it has a whole lot of useful build tools available to you to use. Eclipse has a Gradle plugin available which allows you to use Gradle projects with it. See link below.
To give you a idea of how Gradle is used professionally. Android uses it by default to maintain their projects now. So Android java projects uses the Gradle build tool to maintain its library sources, compilation processes and such.
The difference between a Gradle project and a normal java project is that a Gradle project has a list of pre-defined scripts available to you which fetches the libraries, compiles them and prepares them before exporting the final bundle (jar). So really all Gradle does in before hand is fetch the libraries and prepares the specified tools before compilation so you won't need to mess with them your self. It prepares your project directory and remotely maintains your libraries so if they're available from a repository then it'll make sure to prepare them appropriately in before hand and setup your projects directories.
So really the difference you'd physically notice is that instead of using the default Eclipse export button to create your bundle (jar) you'd instead use a button from the side menu which the Gradle plugin adds and also you'd cleanly list the libraries in a structured order in a file that gets added to your project root.
If you want to get a basic understanding of how it works and really want to start to proffesionally or formally structure your project then try to create a very basic android app in Android Studio. see link below
If this isn't what you want at all and don't want to take it to this advanced level yet then adding the library bundles into some kind of lib folder that's located in your project root is properly best practice.
If you wonder why? Well basically different projects might use different versions of the library which may add or remove support to them. So to keep the versions consistent and make sure to have the right version available to you, you have the direct source near the project it self.
Here's some useful link:
http://www.vogella.com/tutorials/EclipseGradle/article.html
http://developer.android.com/sdk/index.html
I have to do a very laborious task on a regular basis and am looking for a way to automate the process.
I have to Clone 2 git repos, open in eclipse, add one repo as a dependency of the other,c hange package names, refactor, replace the res folder with another and build.
I want to write a script or something that will automate the whole process. Is this possible? If so where do I start?
Is this possible?
Um, sure.
If so where do I start?
I would start by choosing a programming language and toolchain for doing the work.
A slick solution would be to use Gradle with the Gradle for Android plugin, as it already knows how to do the build. "add one repo as a dependency of the other" can be done right from the build.gradle file. If your objective of "change package names, refactor, replace the res folder with another" is simply to have a different application ID (e.g., to allow it to be uploaded to the Play Store as a distinct app from others), Gradle for Android can do that just via applicationId, without any actual changes to the code itself.
However, you do not have to use Gradle. You are welcome to choose any other programming language, at least one that can run external commands to do the builds.
Try Jenkins its a continuous integration server.It can even pull code from the github repo and produce android builds without having to go through the tedious manual steps
Hope this answers your question
I found some cool android libraries the other day and decided to try some. But I'm having trouble correctly importing the library.
This is the URL of the library : https://github.com/dmytrodanylyk/android-process-button
I first tried importing the library to eclipse (and move the files in java directory to src directory and set the project as library) and importing the sample to eclipse and set it to use the library project (Properties->Android->Libraries). But it didn't work. The layout files said it failed to instantiate [custom widget class].
The I tried importing the .jar file to libs directory (and update the java build path) but it didn't work either. It showed errors in the java files too.
I then tried copying all the java and layout files to the sample project directory and it worked. But I'm guessing that's not the way to work with 3rd party libraries.
I first thought it's some error with the library but all the other libraries I tried to import to my projects faced the same problem.
Can someone walk me through how to correctly import a 3rd party library to my android project?
The best option you can do is to use gradle as your dependency manager.
The library you have posted is using Gradle so you can link to this library in this way:
dependencies {
compile 'com.github.dmytrodanylyk.android-process-button:library:0.0.7'
}
And voilá! You have your library ready to use in your app :D
I'll let you a couple of useful links to use Gradle properly:
Mark Allison's tutorial about Gradle It will explain step by step how Gradle works (keep in mind that is using an outdated version of Android Gradle plugin, you have to adapt the version to the current one which is 0.10)
Official Developer Docs about Gradle In here you can find another step by step tutorial to configure and use Gradle (this one is more updated).
You can use Gradle directly in Android Studio (Intellij) if you don't mind to change your main editor.
If you want to stick around with Eclipse then this stackoverflow link may be helpful!
EDIT:
Oh! And if you want to search already Gradlized libraries you can navigate to Gradle Please!
I see the library uses gradle. So if you use gradle for dependency management or Android Studio (which uses gradle by default) importing will be a breeze. The installation instruction for gradle is even available at the github project site.
dependencies {
compile 'com.github.dmytrodanylyk.android-process-button:library:0.0.7'
}
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I code mostly in Java and use Maven for all of my projects. I do really love using Maven since it is easy to download the sources and documentations, and, more importantly, I don't need to keep the copy of the external libraries under my project source code folders.
I have started to develop an Android application and I found that the Android plugin for eclipse are terribly good. However, all provided examples are not maven projects so I do not know whether, if I use maven, I would still get all the functionalities from the Android plugin or whether there is any drawback from using Maven.
So the questions are:
Do all features from Android plugin for eclipse still work?
Is it going to be more difficult than using the normal build (I believe it is Ant but not certain)
Any other drawbacks, e.g. the file size of the final application (Maven tends to bundle a lot of things together) or the difficulties of getting the latest libraries on maven repository (which is probably differnt for Android).
Please do not point to this maven support for android projects?
I would like an answer from experience developers. I already know that it is possible to use maven for an Android app. All I need to know is whether I should use it.
My teams current task is to develop an Android app. Since it is a small app and also some kind of prototype we decided to evaluate Maven and the Android Eclipse plugin.
In short:
After two developers spent three days, we were not able to gain the Android Eclipse plugin functionalities in our Maven project.
The R class was not updated according to our resources
We were not able to start the application directly from within Eclipse in the emulator and/or an attached device
Because of these issues which impeded our development sincerely we decided to develop the app without Maven.
But if any of you knows how to fix these issues I would love to hear a solution!
If you want fast running tests you are nearly forced to use maven. As robolectric is the way to go then. And they said Roboletric is probably easier to set up via maven under Eclipse (they are using IDEA).
That said, did you read this post or that? And what error message exactly did you get?
Typical things I made wrong:
use maven >= 3.0.3 ! And avoid that embedded thing in eclipse. (This was necessary only for robolectric, if I remember correctly)
use ~/.m2/settings.xml as described on the robolectric page to set up the android path
specify your android sdk also properly in the local.properties and under Preferences -> Android -> SDK location
Further read this and that or just try the mavenized robolectric example itself, which worked for me. Import it as existing maven project.
Install the necessary sdk (in my case 2.2_r3) via maven-android-sdk-deployer and
export ANDROID_HOME=/path/to/android/sdk
mvn install -P 2.2
And did I mention this strange tool: m2e-android - not sure why one needs so many stuff with Eclipse ... here you can install it via software updates http://rgladwell.github.com/m2e-android/updates/master/m2e-android/
Hopefully I remembered all steps correctly. Good luck!
Update:
Switching back to normal Android stuff without maven under Eclipse as the IDE makes strange stuff: http://groups.google.com/group/robolectric/browse_thread/thread/ac814076c40d9df1
But the nice thing of this Maven adventure is that I can now easily test and debug my projects via NetBeans :)
As we all know Android Devolopment migrated to Android Studio from Eclipse.
The Android Studio build system consists of an Android plugin for Gradle. Gradle is an advanced build toolkit that manages dependencies and allows you to define custom build logic.
The build system is independent from Android Studio, so you can invoke it from Android Studio or from the command line.
The Android Studio build system supports remote Maven dependencies. As you know, Maven is a popular software project management tool that helps organize project dependencies using repositories.
You can build your Android apps from the command line on your machine from Android Studio,thus by avoiding the mess of plugins as there in Eclipse.
Check out this tutorial for Building Android Apps with Maven.
Refer here for more about Gradle build
I recommend avoiding Maven for professional development on Android. Here's why:
Google is investing time into keeping Android Studio integrated with Gradle. So maven is extra work right off the bat.
If you have to use Maven (e.g. to manage dependent libraries), then Gradle can use the Maven plugin. See https://docs.gradle.org/current/userguide/maven_plugin.html
By making maven your primary build tool you'll be downloading a massive amount of dependencies that you don't need and you're not sure where they come from. This goes against the notion that for your Android app, you ideally want just your code, and the android platform. In other words you're involving a lot of libraries/code you don't need.
In short, using maven as your Android build tool adds much more work than is necessary and creates a management nightmare (IMO).
Try this to illustrate:
Heat a pan on a stove.
Hold up a raw egg. Say "This is your android application."
Crack the egg into the pan.
Say "This is your android application on maven-with-rats-nest-dependency-tree-and-unknown-code-downloads-that-you-don't-need-anyway."
Wait for the egg to burn to a crisp.
Say, "This is your android application when the maven build packaged a useless or bad library with your Android application."
I have been able to use maven for android application development using Android Development Tools for Eclipse (Kepler) and Android for Maven Eclipse 1.0.1 (m2e-android). Follow these instructions http://rgladwell.github.io/m2e-android/. After you have created your new project with the android quickstart archetype modify your pom.xml. Add the android platform version. Eclipse (m2e) will report an error on the pom.xml on the android-maven-plugin declaration, to fix this issue follow alexander's response in Error in maven pom xml file: Building Android project. Then update the maven project using eclipse and that should be it.
From my own experience in Intellij. I used Maven as a build automation tool for my android development process. I started learn it with "Android Application Development with Maven" from Packtpub.