Adding reference to shared project in an Xamarin iOS project - android

I'm currently trying out Xamarin (on a MacBook, all needed SDKs are installed) and have created a shared project solution.
Within this solution folder there is the autogenerated shared project (called "Project") folder and two projects which I created: An Android project ("AndroidApp") and an iPhone unified single-view Project (iOSApplication).
Now I have added the references to the shared project in both of the other projects so i can use the code from the shared project in the other ones.
So I add "using Project;" add the top of the android project's MainActivity file and it works. I can use classes of the shared project in my Android project.
Doing the same in the iPhone project does not work, and I don't know why.
I'm almost certain that it is my fault because I misunderstood something but I can not imagine what.
Here is a picture of my current workspace in case my discription is unclear.
http://pl.vc/4ndf3
Thank you in advance.

Related

Create STANDALONE Android Studio (1.5) library project

I need to create an Android Library and deliver the final .jar file to the clients.
I am new to Android development (three days). I've been developing iOS for the last 4 years. I went through Google's official documentation and tutorials to get a feel for the platform (I don't want it to be obvious that an iOS guy was writing the library).
I don't have any problems with Java, but I do with Android. I decided to go with Android Studio since it is the official IDE. I am using version 1.5.
PROBLEM:
So as I said, I need to create an Android Library and deliver the .jar file to the clients. I would like this Android Studio project to be a standalone library project with its own unit tests. I don't want to create an unnecessary App project, and then add an Android Library module to it. I want to create a separate App project which will include this .jar file, so I can test it in the way it will reach our clients.
I've seen a lot of options online for how to accomplish this, but all of them seem a bit "hacky" (e.g. rename this folder, change that app-project-setting and make it a library project). Is there no way to create a Library project from a new project wizard in Android Studio?
What are your suggestions on how I should proceed with this? Is there some elegant solution to this without these tricks to re-configure the App project?
EDIT
Here is what the new project wizard looks like:
I select "Add no activity" here
This may not feel comfortable for a person from other platform/IDE/world, but this is The Way. Personally i'm getting annoyed with Xcode every time i use it in the exact same way you're annoyed with AndroidStudio now. But lets get down to business:
Create an empty project and select "Create no activity".
When everything is set, go to "File\New\New Module" and select "Android Library"
Give a name for created library and click "Finish".
(Optional) go to "Run\Edit Configurations" and set everything like below:
Now open the librarie's 'build.gradle' file. Make sure to open the file from exact same folder which is named with your library name, because there are a couple of 'build.gradle' files all over the place. Remove support-library entry from the file:
Write some code and when you're ready to deploy the library set everything like this:
Go to "Build" menu at the top and select "Build APK".
And about unit tests:
**Edit 1: **
If you really want to remove the 'app' folder, than follow instructions on a picture below:
You can create Library Project instead of Normal Project,then your output product will be a jar or aar as you configured.If your library has resources then build it as aar,or it will be jar.
When you created a project as yo are doing,click File->new Module,then will like this:
If your library project have resources or will use API of Android,then choose Android Library,else choose Java Library,Android Library will build aar as product whild Java Library build jar product.

Creating standalone android library project using Android Studio (0.8.14)

I see there is option to create module/ android library project with in a project, but don't see any way to create a standalone library project/module that could be shared across different projects. It used to be very simple in Eclipse. When I try re-using an existing module within a different project, AndroidStudio simply creates a copy of that module in new project. Thats what I don't want, I want to re-use my existing code. This link seems to have answer I'm looking for, but not working for latest build for Android Studio.
There are a couple of ways I've tried doing this, a quick and easy way to do this is to symlink your library module directory to a directory in your project and add it to your settings.gradle. A better way to do it is to import the library module as a VCS project (local git works fine) It will still clone the library module into each project but changes made to the library will be consistent across all of the projects using it.

How to include a custom library from GitHub into my Android app?

I am trying to use this library off of GitHub for a Segmented Control in Android.
My problem is that I do not know how to include the provided library into my existing project. I've tried copying the src and res files (of the library and sample) into my project and modifying their package names to match mine, but the files are filled with errors and will not compile.
I am new to Android development, and so I am unsure how to bring these files in to my project so that I can use them and create the desired segmented controllers.
Note: I am using the Eclipse IDE from the Android website (ADT v22.6.2).
Hi there you will want to actually clone the whole repo and import that project as its own project and then reference that project via this method. Eclipse Android project, how to reference library within workspace?
Good luck.

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.

Android Library project out of sync in Eclipse

I have an Android Library project with some Activities and Views, referenced by an Android Application project. The application project has a "linked" folder marked [Android Library] with the sources of my library project.
One thing that seems strange to me, is that the same source file can be opened twice, from the linked folder and from the original library folder. This often results in files being out on sync, and all sorts of nasty things happening.
Any idea of what's going wrong? Thanks in advance!
This is expected behavior. If the same physical folder is added multiple times via resource links, the synchronization state of each of the folders is tracked separately. Here are your options:
Deal with having to manually refresh folders from time to time.
Turn on auto-refresh under Window -> Preferences -> General -> Workspace -> Refresh automatically. I believe this performs ok Windows, but can be very slow on Linux. Actual performance likely depends on the size of your workspace.
Re-structure your projects such that you are not using linked folders to bring in library code. I don't know anything about Android development or ADT, but the standard approach for other Java apps is to add a dependency from app project to library project via Project Properties -> Java Build Path -> Projects.
Check your package name in Manifest file it should be same with your project package name.

Categories

Resources