How to import individual projects from Android Source Code - android

As far as I understand, all the built-in standard apps like (email, music, calendar etc) are built using the same API. So I should be able to import a project like mail / music etc without checking out the full source repository of android. I'v been trying that but I am getting compilation problems like class resolve failure.
Am I doing it wrong? Do I have to get the full android source project to import a project like Mail ?

These apps are open source (mail, music and calendar). But they depend on internal classes and resources and can't be compiled with the SDK

You could pull a Git clone of some particular app. For example - the EMail app from
https://android.googlesource.com/platform/packages/apps/Email/
The first problem is that Google are using MK files for building inside their android projects and Eclipse do not use them. But you can compile it because you have the sources, the XML resources and the manifest also.
The second problem is to deal with the dependencies. For example the gallery app may depend on few camera classes. You can manually copy them to your project.
Other way is:
Using Eclipse for writing code and testing if it builds correctly and using GNU Make 3.82 from http://www.gnu.org tool that will build the supplied Android.MK file and run the app.

Related

Skype for business android SDK issue, Failed to load native library

I am trying to implement an app using Skype for Business Android SDK's
this is the document that helps to configure the SDK, which didn't help me integrating the aar files.
https://msdn.microsoft.com/en-us/skype/appsdk/gettingstarted
so, i integrated the libraries using new module --> import jar/aar files, that resolves my compilation error, i can now also get the class references from these SDK's. but when i run my application it says Failed to load native library.
there is an example on github that uses Skype for business SDK. where everything works like a charm. but i am still unable to figure out why it fails to load library in my application.
Does this Unspecified in my attached screenshot has to do anything with why my app is failing to load libaries?
Explicitly adding Architecture specific Native libraries helped me.
SFB currently supports only armeabi.
1) create a folder in your project's main lib/armeabi
2) Extract Sfb library marked in yellow in the pic below.
3) Navigate to SkypeForBusinessNative/jni/armeabi
4) you will find five .so files, marked in white in the pic.
5) paste them in the folder you created in step 1.
You will have your application running.

How should I use R queries in an Android Studio application project to be able to easily convert the project into library project later?

The question have basically two parts, because answers can "deactivate" other questions:
Can I use android application projects (written in Android Studio) in a Unity game engine project somehow? If yes, the questions below are not important, but I think the answer is no.
There are Android java developers, and there are Unity game engine c# developers in here. Some of us need to create an Android Studio application project, and they should have some kind of visual surface for that during the debugging.
After this, it would be better if they would be able to give the code to us as a library project, because a jar file should be created for the Unity, because the final surface of the app will be in Unity.
I know there are topics about "how to convert an application project into library project", and they works perfectly in a simple example project. But this can't be made easily, if the R method and R variable calls (or I don't know the name of that, R.id.something and R.something, etc.) are in a lot of java files. It's a lot of work cutting them out. I simply can't build the library app, if it has these R things in them. It was the case in a big Android application project, but I don't know if there would be a good workflow idea for a new project.
Since I'm not an android developer, I don't know how should this workflow in a new project to be made easily. Any idea?
The "R" in android development refers to the R class used to access the res folder in an android project, wich contains all other resources needed (images, layouts, strings)
Unity allows you to access native and custom plugins that you can import to your editor, I recomend giving a good read to the official documentation to Plugins for android in the unity website
https://docs.unity3d.com/Manual/PluginsForAndroid.html
The Android plugin mechanism also allows Java to be used to enable interaction with the Android OS.
There are several ways to create a Java plugin but the result in each case is that you end up with a .jar file containing the .class files for your plugin. One approach is to download the JDK, then compile your .java files from the command line with javac. This will create .class files which you can then package into a .jar with the jar command line tool.

Android - Java Packages & Libraries

I want to be able to use the Open Source AOSP Material Design Calculator into my own app where the calculator is one of various other features on my app. I found the code here. My question is the following:
Is it possible to add this open source calculator to my app by simply installing it as an additional package in my app codebase? If so I would like to request some basic overall steps on how to do so. Should I just import it in my project as another package? What do you foresee being some of the steps on how to achieve this (Android Studio specifics).
As the calculator is consider to be AOSP and open source, would it be ok for me to add this package my my codebase? If so what are some of the notifications I as a developer must put on the app to inform users that I'm using an open source project as part of my app. I'm assuming this is required.
In the end my app will have many features where the AOSP Calculator will be one of them. This calculator will be reached via an intent and the user should see the calculator with the same functionality except it will be visually redesigned. The whole point of open source projects is so that developers don't have to reinvent the wheel every time, with that in mind I look forward to any feedback you may have about these questions.
I was having a similar issue in the past. The following steps will ensure that you can integrate this app as a library in your project.
1) Clone the project in your local machine (git clone ...)
2) The project is build using Gradle. Before you do anything go to the build.gradle file and create this task at the end of the file:
task copyDeps(type: Copy) {
from configurations.runtime
into "${buildDir}/libs"
}
3) Now fire up a terminal and navigate to the root of the Calculator project. Type gradle --refresh-depencencies in order for gradle to fetch a couple of jars needed by the Calculator project. When this finishes, type gradle copyDeps in order to copy the dependencies to the project's libs folder (if the folder does not exist create it).
4) Now that the project is ready open your IDE (mine is Eclipse but the steps are pretty much the same). Import the project and then mark it as a library to your project
5) Now upon deployment the Calculator will be packaged with your application and you will be able to fire Intents and open it (check the calculator's manifest file.
As for the Calculator project, yes you have to include somewhere a simple notification. For more check here.

What are Pros and Cons of using Library project(In Eclipse)in my existing Android project?

I am working on a Android app in which I would like to add plug and play module functionality ,Say I have Two android project
[A] An app for capturing a image using camera and storing it in memory
[B]Enabling map and locate current location .
now I want to add add this functionality in my Another Android app.While going through android developer link and Android Library Projects - Tutorial I figure out that to use plug and play module I have to make my above project as library project so that I can use it in my new app ,now my questions are
1 Is this only way to use library project to add plug and play module
functionally in my app or there are another way also?
2 what are the pros and cons of using library project in order to add
plug and play module functionally?
basically I am researching on how to add plug and play service in my android app and trying to find best solution ,so any clarity on this topic will be extremaly helpful !!!
thanks in advance !!!
An alternative would be to use a linked source folder. In Eclipse, you can set this up in the project settings in the Java Build Path section. You can choose some source code directory outside your project that will virtually be in your project's space (and other projects that use it will do the same). I find this to be handy just from an IDE UI standpoint when I'm co-developing a module along with an app or two. What I don't like about library projects is that they sometimes don't update correctly within your project so you have to rebuild it and your project or clean your project to continue. Also, the module is simpler because it's just a directory of source code files, not an entire Eclipse project.
One other downside of libraries is that they can introduce conflicts that can be a headache to fight. For example, your library might have a different version of the Android compatibility library in it than your main project, and therefore give you compile time errors. Or there are sometimes errors with duplicate libraries, and you have to go fool with the Order and Export settings of your project.
If your module is going to rely on String, layout, and image resources, etc. that are common to all apps that implement the module, then a library project will be easier to work with so you don't have to pass all your resources in through your module's class constructors and duplicate them in each project.
A third option is Gradle, although as far as I know, that would essentially just help automate one of the above two options. I'm not very familiar with Gradle.

Android library project as jar file for distribution, like google analytics

I have seen this question, and have some more doubts regarding creating a jar file which I can distribute and can be used in any android applications.
What my requirement is
As I said, I want to build and distribute a closed source library. I
don't want the source code to be visible.
In that library I don't want to use any assets, layouts, resources
etc. But I want to use some android specific codes, like getting
android device id.
The most popular answer in the above linked SO question tells to create a regular java project and import android.jar in it. I tried to do that, but I don't know how to add android.jar to any java project. I would like to get some clarification on that too.
Moreover I would like to know if there are any other methods using android sdk itself (without using java project) create a closed source library jar file.
I think what I want is possible, since google analytics for android native apps seems to have done it. I am sure in the .jar file they distribute they are using android specific codes, since there seems no other way for them to get the device information to display in the analytics viewer.
EDIT : CAN SOMEONE CLARIFY THIS??
I think I have made some progress. This is what I have done
Created a regular android project (not library project, the "is
Library" checkmark is unchecked)
In the project I have coded out my logic. It uses some android
specific classes like SharedPreference, UUID, PackageManager. But
nothing related with assets, layouts also no class extending
Activity. Just a java class extending java.lang.object
Exported the project using Project->rightclick->export->Java->JAR
file. In the next screen I unchecked the checkbox near
AndroidManifest.xml. Set a destination directory to export and
clicked next thrice with keeping the default settings. Then I clicked
Finish, and got a lovely libMyLibraryName.jar at my desktop.
Then I created another android project, added this libMyLibraryName.jar to new project using project->rightclick->properties->java build path -> libraries->add external jar.
And I tried to use my class in the library, in my new project
MyLibraryClass objClass = new MyLibraryClass(this);
And I was able to compile and run successfully. I even sent the library to one of my co worker who was able to use the library in his on machine (Just making sure library project in my workspace wont influence the project using it).
Now I have 2 questions.
1) My first question is , what they meant by the term "true library" in the below given documentation ? Is it any non android java project which can be exported to a JAR file?
However, a library project differs from an standard Android
application project in that you cannot compile it directly to its own
.apk and run it on an Android device. Similarly, you cannot export
the library project to a self-contained JAR file, as you would do
for a true library. Instead, you must compile the library indirectly,
by referencing the library in the dependent application and building
that application.
Well this portion is taken from documentation under title "Library Projects".
2) My second question is, anything wrong with the way I have created the JAR file? Any possible pitfalls which might bite me back later? I would like to make sure I am not doing something terribly wrong, before using it in my important projects.
I might add that I didn't try the method of creating a JAVA project and importing android.jar. I am ready to try that one, if what I have done currently is wrong.
The android.jar will be located where you installed your Android SDK. Under the platforms directory there should be a number of other directories named android-<version>. The android.jar will be there. Choose the one specific to the minimum android version you are targeting.
Once you have that, copy it into your project. If you're using eclipse I think you can just cut and paste jars straight into your project, right click and add it to build path. If you're not using eclipse or any other IDE, you just need to ensure that the android.jar is on the classpath when building your jar file.
After that your newly built android library can be dropped into any Android project.
In answer to your additional questions:
What they mean by a true library is a jar file as opposed to an Android library project.
I don't think there's anything wrong with the way you created the jar file. I would have made it using the android.jar as I mentioned above but your way should also work. To verify this I would examine the jar contents and make sure all you have in there is .class files.

Categories

Resources