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
Related
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')
}
I imported a material Dialog library from Github.
https://github.com/drakeet/MaterialDialog
And I imported the library in Android Studio.
However, now The Android Studio says "Gradle project sync failed, basic functionality (editing, debugging) will not work properly.
I tried alternative answers to similar problems from other questions here,
Gradle project sync failed?
Android Studio Gradle project sync failed
But, none works for me .
The error I get in console is : Error:Dependency ZyiaAlarm:materialDialog:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: F:\ZyiaAlarm\materialDialog\build\outputs\apk\materialDialog-release-unsigned.apk
My doubt is: Any way to restore the things back, I mean to get the gradle as it was as I am a beginner, there's much to learn about gradle.
OR
anyway to fix this library I imported ?
Any help will be appreciated!
Too long for a comment.
It is not clear how do you import it.
If you would like to build locally this library, you should have this type of structure:
root
MaterialLib
build.gradle
app
build.gradle
build.gradle
settings.gradle
where MaterialLib is the folder MaterialDialog/library from github.
You haven't to import the other folders from github.
Also in
app/build.gradle you should have:
dependencies {
compile project(':MaterialLib')
}
and in the settings.gradle you should have:
include ':app',':MaterialLib'
However I suggest you avoiding the local library.
Remove the MaterialLib (don't import code from github).
Just add to your app/build.gradle these lines:
dependencies {
compile 'me.drakeet.materialdialog:library:1.2.2'
}
In this you should have this type of structure:
root
app
build.gradle
build.gradle
settings.gradle
and in the settings.gradle you should have:
include ':app'
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'
}
In my app I'm using Guava library. I have referenced it in my build.gradle file only as follows:
dependencies {
compile 'com.google.guava:guava:13.0.1'
}
My app rebuilds and runs fine. However when I'm trying to add a new something from Guava library then the compiler complains that it can't find the class.
For example: when I write
import com.google.common.base.Preconditions
in my new file the compiler says 'cannot resolve symbol common'.
But my old files are rebuilt fine. How so? Do I have to mess with Project|Structure? I specifically wanted to list any dependencies -only- in build.gradle.
It seems that doing a "sync project with gradle files" helps.
In Android Studio, select :
Tools > Android > Sync project with gradle files
Hey I've been trying for hours to import an Android library (BetterPickers latest commit) into my project using Gradle
After importing and setting it as module, I get compilation errors. It seems like something is wrong with dependencies in my build.gradle .
build.gradle of library project
build.gradle of main project
As you can see, Android Studio suggests an autofix but it's not helpful.
When I try to run the project/Gradle build, I get compilation errors since the library project is dependent on nineolddroids lib. When I try to add nineolddroids to the dependencies I get a different error:
Could not resolve all dependencies for configuration ':sub:bp:_DebugCompile'.
Could not find com.nineoldandroids:library:2.4.0.)
I guess both of them are derived from the same thing.
How can I fix this?
A few remarks
Using latest Android Studio (0.2.5)
Android Support Repository is installed
In the main project, the support lib is imported just fine and I get no compilation errors when using classes from support lib
Tried many ways to import the library project, including answers from here