Error when adding libraries on Android Studio - android

I'm trying to create an app for android (google Tango) that uses thrift to send some information to a client. I take a sample Tango app which runs without Thrift. Then when I add try to add some of the Thrift dependencies (like slf4j-log4j12-1.7.12.jar) I suddenly get errors like
error: package com.google.atap.tangoservice does not exist
I don't get what's wrong, it worked before...
Why does this happen, and how can I fix it?
Thank you
UPDATE
The way I added the library was by clicking right on App>new>module then I chose import jar, and selected the jar. Then I went to project structure and in dependencies I added the module of the jar I imported.
Adding it like this did not help me resolve the conflicts I had before:
import org.slf4j.Logger;
giving me the error "cannot resolve symbol 'Logger'".
And it also introduced the errors previously mentioned.

Have you tried adding a dependency to your build.gradle file like this:
dependencies {
compile 'com.google.atap.tangoservice'
}

If you are using local jar dependency then add it like this to the build.gradle:
dependencies {
compile files('libs/something_local.jar')
}

Related

AsyncTask.java cannot resolve symbol for Nullable, Mainthread, WorkerThread

I'm pretty new to android studio, but i got this error and i can't run my project. I saw a lot of answers which suggest to add the support-annotations dependency, but I'm using appcompat so i don't need that. Any thoughts?
Do you have the Android Support Library?
To do it add this to your build.gradle file of the "app" module:
dependencies {
...
implementation "com.android.support:support-annotations:27.1.0"
}
Then sync the project.
Sometimes you can do this automatically by pressing Alt+Enter over the error message and selecting the solution.
You need to fetch the libraries that contain the imports, in your build gradle file of your module add the line inside dependencies tag:
api 'com.android.support:support-annotations:X.X.X'
or
implementation 'com.android.support:support-annotations:X.X.X'
Where X.X.X is the version of the rest of your support libraries.
You should read this article that explains how to implement this with more detail.

How to import a library from github?

I don't understand how to add a library in my new project.
https://github.com/txusballesteros/bubbles-for-android
I saw similar posts but I don't get the library in my project.
Error:Configuration with name 'default' not found.
And when I add the library can I change the original source code and can I use it because I read about the same License ?
Please help me, I was trying many methods and I failed.
Locate your build.gradle file:
Go to android view (easiest this way)
Locate Gradle Scripts folder:
Locate your correct build.gradle file (watch it, there are 2 of those who look similar):
Add the this statement (compile 'com.txusballesteros:bubbles:1.2.1') according to picture:
Good to go
Add the library dependency in your app level build.gradle file(not project level). you don't need to download any library file just add this dependency and sync the project
dependencies {
...
compile 'com.txusballesteros:bubbles:1.2.1'
}
Add following to your Build.Gradle under dependency block and then sync. project. Now you can use that library methods in your code.
compile 'com.txusballesteros:bubbles:1.2.1'

Importing library gives error in Android studio

I am new to Android Studio. I am trying to work using the android-map-utils library. But it is giving me the following error.
`Error:(64) A problem occurred evaluating project ':library'.
> No such property: sonatypeUsername for class: org.gradle.api.internal.project.DefaultProject_Decorated`
Can anyone help me with this issue and also tell me a easy way to import libraries in android studio?
I had a similar problem while I was migrating from eclipse. I resolved my issue by using the gradle method of including the library (as opposed to importing it as a module and using it as a dependency).
Add the following dependency to your Gradle build file:
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.3+'
}
source: http://googlemaps.github.io/android-maps-utils/#start
I wasn't able to comment.
Applying gradle dependency as link doesn't allow us to view it's source properly.
So if you are interested in viewing source too, in Android Studio itself
You should try adding library as a module project, i.e.,
File -> New -> Import Module -> (Dir of Library)
after importing, you'll face an error, which can be resolved from - Adding Maps Utils Module

android studio cannot resolve import org.json.JSONObject

I used libgdx to build my project and I am having issues using the JSONObject class. When I add import org.json.JSONObject, it says it cannot resolve. How do I add that library to my project?
Here is what I have tried without success:
I downloaded the json-simple-1.1.jar and put it in core/build/libs folder. Could not use import.org.json.simple.JSONObject either.
When browsing the tree in Android Studio as "Packages" dropdown, I can see the classes I want under "Core -> Libraries -> org -> json" but I cannot add them to my project. I get a "cannot refractor, class is in a jar file" error.
Is there something I have not tried yet to solve this issue? I feel I will run into this again as I try to use other external libraries.
Thank you.
If you are using LibGdx, it does not come with a Gradle setup, making multi-project builds streamlined.
You need to add implementation 'org.json:json:<version>' to the dependencies block of your top-level build.gradle.
To find the latest version, see http://mvnrepository.com/artifact/org.json/json/
For example, using the latest version at the time of writing:
dependencies {
implementation 'org.json:json:20200518'
}

the import com.google.maps cannot be resolved (clustering.Cluster)

I am trying to use clustering in my application. However on the import statements I get 'the import com.google.maps cannot be resolved (clustering.Cluster).
Also, when using ClusterManager I get 'cannot be resolved to a type'.
The rest of the google play services are working fine.
Are you using Android Studio, or Eclipse? Might need to check your gradle file (Android Studio for example) to see if you have the library/module dependencies lined up. If you are using this library (https://github.com/googlemaps/android-maps-utils) for example, your gradle file should have something like :
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.3+'
}

Categories

Resources