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

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.

Related

Developing Android 9.0 eSIM LPA (system app)

Trying to develop android LPA system app for eSIM with the new Pie API.
The doc says to extend the abstract EuiccService class. But this class is not in the official SDK, and the link in the docs just leads to corresponding file in the android source repo.
I tried using this file/class as a dependency, but it references other internal android classes/annotations and causes build/IDE errors.
Does anyone have an idea how to use this?
Do I really have to pull android src code and somehow reference required class from it?
EDIT: I think I've solved it, found couple of potential solutions, but they were a bit cumbersome. Used the android.jar from here: https://github.com/anggrayudi/android-hidden-api (contains modified android.jar with hidden APIs and internal resources). It didn't work when i replaced the whole file and resulted strange build errors, but i manually transferred the android\service\euicc\ folder to original android.jar of android-28 sdk and it works perfectly (class is available and apk builds without issues). And no need to waste time pulling and building AOSP.
EDIT #2: apparently not fully fixable atm. There's issue with android gradle plugins (at least 3.2.x-3.3.x) where during full sync some build task generates mock classes from android.jar and process fails if it's modified (discussion is here: https://github.com/anggrayudi/android-hidden-api/issues/46). Error looks like this:
Failed to transform file 'android.jar' to match attributes {artifactType=android-mockable-jar, returnDefaultValues=false} using transform MockableJarTransform
There's a workaround for that, though inconvenient:
when you need a full sync for the project, replace the android.jar with original, run sync, restore modified android.jar, the IDE now will run indexing and classes will be available again with build working until next full sync.
Will update this post if/when it's fixed or new solution is found.
EDIT#3: here's probably a final solution for EuiccService case (turned out pretty obvious):
Instead of adding 'android/service/euicc' folder to android.jar, just put it in a separate library and add it as a compileOnly dependency. Since the classes were not in the SDK, the lib should not cause conflict (would be the case if you need to use modified framework or access hidden APIs in already existing classes).
If you are going to create a System APP, you will do it in several ways:
You could call a part of the SystemAPI (a method for example) by reference.
You could make the aplication as a part of the AOSP Project (Downloading the AOSP code, and introducing your app as part of packages/apps/)
You will be able to access system APIs on a rooted device or if you have system permissions (this happens when you flash your app into the device as part of the system image).
However, if you want to be able to call the EuiccService class from Android Studio (for coding purposes), you'll need to add the Android framework jar to your project.
The steps are provided below:
First, you will have to download and build AOSP and generate a framework jar for your target Android version. Check the documentation here to get an idea of how to download and build AOSP.
After a successful build all framework classes are compiled into a jar called classes.jar which can be found at the location out/target/common/obj/JAVA_LIBRARIES/framework_intermediates.
Get this classes.jar and add it to your Android project as a jar file.
Gradle sync the project and start coding.
Please beware that you WILL NOT BE ABLE TO run this app on an Adnroid device where you do not have system permission for this app.

how to create library ( jar ) in android studio ? [duplicate]

This question already has answers here:
How to make a .jar out from an Android Studio project
(11 answers)
Closed 5 years ago.
I want to create some library that i will use in the future beside my current project.
I can't find a way to create library in android studio.
How to do it on android ?
A library module is useful in the following situations:
When you're building multiple apps that use some of the same components, such as activities, services, or UI layouts.
When you're building an app that exists in multiple APK variations, such as a free and paid version and you need the same core components in both.
In either case, simply move the files you want to reuse into a library module then add the library as a dependency for each app module.
To create a new library module in your project, proceed as follows:
Click File > New > New Module.
In the Create New Module window that appears, click Android Library, then click Next.
There's also an option to create a Java Library, which builds a traditional JAR file.
Give your library a name and select a minimum SDK version for the code in the library, then click Finish.
Once the Gradle project sync completes, the library module appears in the Project panel on the left.
If you don't see the new module folder, make sure it's displaying the Android view.
Visit https://developer.android.com/studio/projects/android-library.html
As introduction I would suggest you to peek into this conceptually simple tutorial. Basically you can start your own library module when you chose your project, without adding any Activity. Then you create your Java Class, usually with a View. When your library is ready, with all its business logic, you can glue everything inserting in the top level build gradle the instruction you are using a library, basically before you remove the following line, that is not needed for a library:
applicationId
(This line in your gradle file is a unique application ID that looks like a Java package name, that identifies your app to the device you are running and in google play)
and then you change this line:
apply plugin: 'com.android.application'
to:
apply plugin: 'com.android.name_library'
When you have a more structured project you can follow the official documentation
As it is well explained the difference between a normal Application and a Library is:
An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest. However, instead of compiling into an APK that runs on a device, an Android library compiles into an Android Archive (AAR) file that you can use as a dependency for an Android app module.
I would not encourage you to use solutions like web services that do it on your behalf, namely just copying/pasting your existing code. In fact a library often needs specific architectural choices, so is important to consider and learn different factors, is not just writing some business logic is quite complex to explain, but you can imagine that also the choice of what the user can see and modify can be crucial. Also should be as much as possible bug free, because once it is adopted could cause problems to the users. I remand you to a famous post, superbly written where you can find some solution to this aspect.
you can use https://jitpack.io/ is very easy publish an android library. just upload your code to github/bitbucket and paste the repository link on jitpack website. that's all

Develop an Android Plugin (Involving OpenCV for android) for Unity in Android Studio

Target Application: Development of an Unity application for android device.The Unity application will use OpenCV for various image processing functions.
Approach Planned:
Develop an OpenCV for android application in Android Studio. This will have a bridge class for sharing data with Unity.
Export the android studio project into jar
Use the jar and other assets in Unity as a Plugin
Access the required functions for image processing using the bridge class in android using the Android Java support classes in Unity.
Build the unity application for Android Platform
Experiments Done:
Already did a set up for OpenCV for android in Android Studio.
Tested sample applications on device by generating apk.
Tested the plugin concepts in unity using DLLs for a windows based application. Dll concepts working fine for Unity.
Final Experiment--
4. Used the classes.jar generated in the build\intermediates\exploded-aar... as a plugin in Unity.
It generates an apk from the unity build. The apk gets installed on a device but fails to open.(Can't see it in the apps menu)
Used this .jar approach based on an answer in the following link
How to export library to Jar in Android Studio?
Problems:
Most of the android plugin tutorials use Eclispe and have the export to jar function. This jar file can be used as a plugin in unity.
Queries:
I found about the jar task which could be included in the gradle script.
But I am not sure how to use it ? There seems to be a lot of version for the jar task creation in Android studio. How to achieve for a project using opencv in android?
I am also confused whether .jar or .aar will solve my purpose?
Should I try any other approach like the android library for achieving the android, Opencv and unity integration.
My take on Solutions:
Generating the appropriate jar in Android Studio will solve the issues.
Else go back developing the opencv for android in eclipse
Useful Links
Can Android Studio be used to create Unity-plugin compatible JARs out of Library projects?
The following project approach is almost the same which I want to acheive
https://github.com/thorikawa/unity-opencv-android
Any help on this will be appreciated.
Update 24th Feb 2015
With the help of this link
Can Android Studio be used to create Unity-plugin compatible JARs out of Library projects?
I am able to integrate Unity and Android.
The android studio project now contains two classes an activity class and a normal java class containing various getter functions.
I am able to call any functions of the normal java class from unity.
But unable to start the activity class from unity.
My Thoughts
I guess unity generates its own manifest file while doing a build for android in unity.
Changing the android studio manifest file accordingly might solve the issues.
Queries
How to start an activity inside the android library from Unity?
How is the android studio generated manifest file provided in unity so that unity merges it with its own generated manifest without any conflicts?
Things Tried
While building in unity, if no android studio generated manifest file is provided, the app functions properly and communicates with the simple java class with getter functions.The values can be obtained in Unity.
If the default manifest file is provided along with the classes.jar the app gets installed but crashes on opening. Even the app name is changed to the one provided by the android studio manifest file.
If any one could help me with this I ll be grateful. Besides I think if I solve this step integrating opencv for android won't be very tough.
Best regards,
Swaroop
First of all you can’t use .aar files unless you have Unity5 (I don’t have but I read that aar support is added). For creating jar I use the same approach that use posted here and it worked for me.
If you have Unity5, If your project is set up as an Android library, it will output an .aar when it's built. It will show up in the build/outputs/aar/ directory in your module's directory.You need to copy those to Assets/Plugins/Android folder
If you want to open an activity from Unity since you added it inside your .jar need to declare it inside your manifest. If you are already using a custom manifest for your project just add it inside your application tag.
Otherwise you need to create a custom manifest for your project. First you need copy the Android Manifest that Unity generates when you compile your game, it’s on folder:
YourProjectname/Temp/StagingArea/AndroidManifest.xml
copy it from there to Assets/Plugins/Android folder inside Unity and add your activity of your library:
<activity android:name="yourLibraryPackagename.YourActivity"</activity>
into that manifest inside your application tag and you should be able to open your activity.

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.

How to import individual projects from Android Source Code

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.

Categories

Resources