Built Android App with Jenkins including Library Projects - android

I have just set-up my local jenkins installation on my mac...
Now i have tried to create an ant built which builds my app as soon as i check-in a new change. The ant script is working great as long as i only use it in the project...
cd into the folder
ant release
It is able to find all library projects i'Ve included (ActionBarSherlock, ViewPagerIndicator, NineOldAndroids, HoloEveryWhere, PocketChange)
As soon as i put this on my jenkins installation everything breaks.
My main folder-organisation is like this:
Projects/Project
Projects/ProjectLibrarys/Library
Eclipse referes to those libraries like this: android.library.reference.2=../Project Librarys/ActionBarSherlock/library
I can't use absolute links (because i think they will fix the issue) but eclipse or ant doesn't like them.
I have really no idea how to fix it?
Will i have to edit the build.xml (i've added it into the folder ext/commonbuild/commonbuild.xml so i have the same android build file for all my projects)
If you need more code let me know.
Thanks in advance...

Ok i was able to solve my issue by adding a customproject.properties file with a seperate link for the build.
There is still one issue. It seems that ant doesn't use the customproject.properties for my library project i've added. This library project includes another library project and as soon as i build it has a wrong relative url.
Does someone know how to use the customproject.properties even for the project libraries?

As bluszcz mentioned, I checked out two modules and i was able to build my apk via Jenkins without having two project.properties or customproject.properties file.
On Jenkins Configure Screen, Under Source Code Management - Subversion Modules,
Give the url for your android project (say, SampleAndroidProject)
https://goxxx.com/svn/repository/projects/trunk/SampleAndroidProject
Provide local module directory as 'SampleAndroidProject'
Provide the svn url for your library project (say, google-play-services_lib)
https://goxxx.com/svn/repository/projects/trunk/google-play-services_lib
Provide local module directory as 'google-play-services_lib'
Save and build again.

Related

Painful Unity project export to Android each build (I'm doing something wrong)

I would like to know if there is a faster way than the following steps to test Unity app with Android (gradle export):
Change something in unity
Build settings & Run --> Export (new Gradle)
Now the old gradle in the Android project is replaced, so i need to copy paste from a backup
The Res folder is also replaced, so I need to copy paste the backup one
Finally Build and Run the APK on the device
Steps 3 and 4 are obviously what makes this process painful (slow), I found the manifest.xml of the Unity android plugin, so this one stays the same (edited it directly in Unity). So am I doing something wrong ? Is there a way to update only parts of the Android project (like, if I only changed one line of a C# Script, just rebuild this one for Android)
Tell me if I'm not clear enough with my explanation :)
EDIT: I Already posted this in Unity forum but I didn't get any answer yet after a day
You can create your own Gradle file.
Put it in Plugins/Android folder and call it mainTemplate.gradle
It will use that.
As far as I know, there is no way to rebuild just part of it.
Unity does not create java files from the c# code. It creates its own modules and uses them directly.
BTW, why are you exporting at all? Why not compile directly to your device?
I just wanted an additional answer for this question even though it is a bit old (just in case anyone else in the future is wondering about this like me). I personally need to make use of both Android Studio and Unity so making a plugin wasn't really an option for me.
Now I have a custom gradle file as explained in the accepted answer. However I have also added an additional resource folder (Explained well by Android here: https://developer.android.com/studio/write/add-resources.html).
You basically just have to edit your custom gradle file to add paths to both resource directories. Add the resources you don't want Unity to overwrite to the other resource folder.
Now every time you rebuild to the project the resources remain and you don't have to copy them back in.
You can export a formal Android project first, using this project to build your final apk.
Then You could write an EditorUtil script in you Unity project, The script does following things:
1.export an temporary Android project to another folder.
2.copy assets folder and jnilib folder or any other folders you want to replace in your formal Android project.
Everytime you want export your project, just trigger the export function in you Unity Editor, It will copy and paste folders automaticlly, then your formal project will be ready for building.

Android studio project files missing from source control

I am looking a source code repository and it only contains code for an Android project i.e. src/main/java/com/.. and no project definition files such as .idea, .iml ,.ipr, .iws - These files are included in the .gitignore file.
There are no files relating to an Android Studio project at all so I cannot open in the IDE. It has been set up for Maven so I can build that way. If I want to run/debug/alter this project what do I do?
Why would somebody exclude all IDE project files?
It's easy, the repository/source code owner don't commit the project files because the source code must be independent of the IDE used by people. The projects files of Eclipse are different from one of IntelliJ.
You can clone or download the source code and even not use any IDE. Some poeple prefer working with editors like Emacs or Vi and build the project using the command line.
There are many ways to create android projects with Android Studio and Eclipse being the main two.
If the author had to maintain project files it would add considerably to the work required as IDEs etc get updates at different rates.
This way the code is "portable" between IDEs and the author can focus on just supporting his work rather than all of the combinations of IDE/Operating Systems.
My Solution
I am posting solution here as I cannot yet answer my own question.
So, I the solution was in the Maven definition. My codebase was an SDK consisting of numerous libraries and sample apps. Each component had a POM.xml and was all contained using a Parent POM.
All I did was import the Parent POM into Android Studio. Once triggered Android Studio would create its own project files using the POM definitions for each component. All the modules were available in one instance and it built and ran instantly. It was truly beautiful :)
Steps: Import Project -> Select directory containing POM.xml -> "Import project from external model" -> Maven -> Next -> continue to create project.

Setting up a project in IDEA with Gradle

I am currently starting on quite a huge Android project which will include up to 5 different Apps. Each of these will be dependent of an android library.
This can easily be done by building the shared android library into .jar file and reference this from each App. But the problem is this project is really on the early stages, therefore the code of the library will change just as often as the Apps. It will be quite a pain to always have the library open in a different project, and build it everytime a change has been made.
First question is how to setup a workspace where you can an App and the library open at the same time, and referencing directly to the library. Without any concern about a .jar file.
If it's not possible any ideas? I can't be the first guy starting quite a large android project with multiple Apps.
In Android Studio do the following:
Create a new project. The project will hold all the different APK projects and the shared library. Use "File -> New Project" or select New Project from the splash screen for AS.
In the project, create a new module for each separate APK. Use "File -> New Module -> Android Application". I'm refering to these types of modules as APK modules.
In the project, create a new module for the shared library. Use "File -> New Module -> Android Library" to create the shared library.
Associate the shared library with each APK module by modifying the "build.gradle" file to add a dependency for the shared library. You must change the "build.gradle" file in each of the APK modules.
dependencies {
compile project(':aaa')
}
Be sure to replace "aaa" with the name of the shared library.
You can have multiple shared libraries if you like.
The code for all the APK modules and the shared library is now accessible under one AndroidStudio project. Another advantage of this approach is that the single project directory that can be turned into a single git repo for the combined APK modules and shared library.
First, IntelliJ doesn't have the same concept of workspace as Eclipse. In a nutshell, the model is as follows: You have one window for each IntelliJ project. An IntelliJ project has one or more IntelliJ modules, which are linked by source. Modules from different projects cannot be linked by source.
Regarding your specific question, I think the easiest solution is to have a single source repo and (multi-project) Gradle build comprising all apps and libraries. This will translate to a single IntelliJ project with one IntelliJ module for each app/library, all linked by source.
If you absolutely need to have separate Gradle builds, and still want a fast turnaround in the IDE, then as far as I know, IntelliJ 13 can add another Gradle build to the same IntelliJ project with the push of a button, and perhaps Android Studio can do the same (not sure). Last but not least, remember that both Android Studio and the Gradle Android plugin are early access previews.
I have tried fiddling with Android Studio and IntelliJ Idea for sometime and the best bet I had was to export everything from eclipse. You could follow the steps below(which is what I usually do.. Does not seem to be a good idea, but it works for sure :) )
Open up ADT or Eclipse and setup a new workspace.
Create the apps and add the library project as a library to those apps. The library project needs to be imported to workspace again(I'm not detailing as I presume you know it)
From File > Export > Android > Generate Gradle Build Files which would generate the gradle build files for the entire workspace. And this then can be opened up in IDEA.
Please do reply if this helps.

Copy and past a app?

I finished a "base app" for all my next apps in eclipse, with admob, contact us...
Can i sort of import this project in a new app and work from there? Or just copy and paste everything and just change the name? How? Like just start a new app with every thing like that app and the work it out from there?
thanks
You can turn your base app into a Library project (see http://www.vogella.com/blog/2011/03/03/android-library-projects/) and your other apps will include this library.
One gotcha with this is that the AndroidManifest.xml from your library is ignored, so you may need to manually copy activities, services, etc. from your library manifest to the real manifest.
I would put my "base app" project in a code repository (git in my case), and then just clone it, change the output name, libs etc in any build scripts. Check that into a new repository and keep working from there.
If you don't use git/svn/whatever just copy your source files and create a new project in eclipse, it's probably easier and less error prone than copying the project files as well and trying to remember all the places that refer to your old project.
Might be a little off-topic but what I usually do is I have pure source (and some build scripts) in a code repository and then outside that (in my eclipse workspace) I create the eclipse project and link the source files into my project. So if I trigger builds with eclipse I get the build output in my project directory while keeping my source directory clean.

How to use git with android libraries?

Like most android developers I use eclipse. When you set up a Android Library Project it is created in it's own directory.
Example:
/workspace/
/workspace/libproject1
/workspace/libproject2
/workspace/myapp
/workspace/mysecondapp
Now myapp will have a project.properties file that will have this:
android.library.reference.1=../libproject1
android.library.reference.2=../libproject2
And mysecondapp might have a project.properties file with this:
android.library.reference.1=../libproject2
How does this work with git? I check in libproject1 and libproject2 in there own repos. However if I use git submodules to connect the library project into myapp it wants to put them in a sub-directory. Then the project.properties files point to the wrong location. Is there a simple solution to this?
Git has nothing to do with the setups unless you use them as sub-modules. I have been having the library projects in separate repos, and each time someone has to clone them, they should be cloning them into a common workspace folder. And it should work.
android.library.reference.1=../libproject2
This means, that Eclipse would try to find your library project in the parent folder. If it finds it there, everything else if fine. If not, you will need to manually tell eclipse where to find it if you clone the library in another location.
Personally, I would not prefer using sub-modules. I haven't tried though.

Categories

Resources