How to add and import .jar files in android stduio - android-studio-2.2

I am following this link: http://programmerguru.com/android-tutorial/how-to-call-asp-net-web-service-in-android/#project-structure to add the soap service in my project. I need to add this file: ksoap2-android-assembly-2.4-jar-with-dependencies in my project.
So my question is how can I add the above .jar file in my project to avoid the red highlighted errors in the image below?. Thanks in advance
Error Image:

Did you tell the gradle script to compile your jar file?
you can follow this link
Android Studio: Add jar as library?
Simply add this line in your app gradle
implementation files('libs/ksoap2_3.6.3.jar')

Related

Android studio issues with linking gradle to android mk file

I am trying add a .so files to a dlib libary in android studio. I have followed the following steps
Migrate from ndkCompile
If you're using the deprecated ndkCompile, you should migrate to using either CMake or ndk-build. Because ndkCompile generates an intermediate Android.mk file for you, migrating to ndk-build may be a simpler choice.
To migrate from ndkCompile to ndk-build, proceed as follows:
Compile your project with ndkCompile at least once by selecting Build > Make Project. This generates the Android.mk file for you.
Locate the auto-generated Android.mk file by navigating to project-root/module-root/build/intermediates/ndk/debug/Android.mk.
Relocate the Android.mk file to some other directory, such as the same directory as your module-level build.gradle file. This makes sure that Gradle doesn't delete the script file when running the clean task.
Open the Android.mk file and edit any paths in the script such that they are relative to the current location of the script file.
Link Gradle to the Android.mk file .
Disable ndkCompile by opening the build.properties file and removing the following line:
// Remove this line
android.useDeprecatedNdk = true
Apply your changes by clicking Sync Project in the toolbar.
However I am getting this error saying the project cant configure.
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':dlib'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:94)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(Li
Caused by: java.lang.NullPointerException
Any help much appreciated.

I don't have gradle.build, why?

I am using Android-Studio to build my app. In order to add libraries, I need to edit build.gradle file but I don't see it anywhere. Even if I changed files-view from android to project and vice-versa .
Why don't I see/have build.gradle ?
Check in your git repository if it contains the build.gradle files.
If not, you can just add manually to your project.
You should have something like this:
root
|--app
|----build.gradle
|--build.gradle
|--settings.gradle
You can also create a new blank project and copy the build.gradle files into your existing project (of course in the app/build.gradle file you have to change the values and the dependencies).
With huge help from #JuLes (commentting on my question) I figure out how to solve it. Here is what I did:
I totally removed Android-Studio following this guidance, then ...
I installed Gradle from this link, then ...
I re-installed Android-Studio following this link:
I am gussing the main problem was that I didn't installed Gradle manually and hence Android-Studio was using some sort of Gradle-Wrapper to allow the application to run.
Now, finally I can edit build.gradle.
BIG THANKS TO: JuLie

Tesseract in Android Studio

To test Tesseract in a simple app found in this tutorial , I need to import it in Android Studio. I get this error:
Library reference ....\tess\tess-two could not be found
How I can solve this ?
Try to set the line
android.library.reference.1=../../tess/tess-two in the project.properties file properly.
This line makes reference to the tess-two library.
Alternative way: remove android.library.reference.1=... line and after importing your project just make referencing to the tess-two library project as described here (in ADT)
Get tess-two with
git clone https://github.com/rmtheis/tess-two.git tess
and put tess in the right place where your main module can find it.

Error while adding mp4parser library to a project in android studio

I'm trying to use mp4parser library in my project. My android studio version is 1.0.2. Here's what I've done so far:
I've downloaded mp4parser zipfile from the link: https://github.com/sannies/mp4parser
I've extracted the zip file to MyProjectName/app/libraries
Renamed the folder to mp4parser
Add this line of code to settings.gradle file:
include ':app:libraries:mp4parser'
Add this line of code to build.gradle (in dependencies block):
compile project('libraries:mp4parser')
Now I want to sync the project with gradle files. This error pops up:
Error:Configuration with name 'default' not found.
I don't have this problem with other libraries. Seems that its only mp4parser that I have problem with. How can I fix this?
If you're including the library as source, the best thing to do is to unpack it somewhere and import it as a module.
The error you're getting is cryptic but it means that the build system is looking for a build.gradle file at that location and not finding it (or it doesn't see an apply plugin statement in the file telling it what to do). I'm assuming that the library you're trying to use doesn't have a Gradle build script.
If you import the library using the Android Studio UI, a build script will be generated for the module and you should be good to go.

How can I add a '.so' library in my android project

I am a beginer in android.Now I am woking with an app that use native libraries.I need to know how to add a '.so' library file in my android project.Any one please help me.
after making your native c code and header file browse to the root directory of your project and run ndk-build command.That will generate the .so file and then place it inside your project/libs folder

Resources