Sync Gradle Android Studio Failed on SlideDateTimePicker - android

I want to create an EditText that could pick date and time at the same time. I found this library but I failed build this library. It says
Error:(31, 0) Project with path ':slideDateTimePicker' could not be found in project ':app'
According to the grade.build file, it looks like we should have this library as a project first. Here is the dependencies that I should add
compile project(':slideDateTimePicker')
How should I add this library into my project? Thank you.

Use this on your gradle:
compile 'com.github.jjobes:slideDateTimePicker:1.0.2'

You need to add library files to your project directory as well. Also add
this line to settings.gradle:
include 'your-library-directory'

There are two approaches. First approach, if you want to use the library out-of-the-box without source code changes. Second, if you want to modify the source code later on.
As dependency on app level; add the following line in your build.gradle file:
compile 'com.github.jjobes:slideDateTimePicker:1.+'
Add as a sub-project to your existing project; add the slideDateTimePicker folder to your projects root folder:
under dependencies on app level build.gradle file add:
compile project(path: ':slideDateTimePicker')
and in your settings.gradle file add:
include ':slideDateTimePicker'

file-> input modle>SlideDateTimePicker, and then: project settings-> add modle->choice SlideDateTimePicker.
or
copy SlideDateTimePicker to you project root path. and add compile project(':slideDateTimePicker') in your build.gradle, add include ':slideDateTimePicker' in settings.gradle
Hope this can help you.

Related

how to add this library to my project?

link I want add the dfu library to my project.
it has a download oètopn, but there is no direct download and it says to use Gradle to add it.
Anyway, the documentation says to do this step.
Clone the project, or just the DFULibrary folder (using sparse-checkout) to a temporary location.
Copy the DFULibrary folder to your projects root, for example to AndroidstudioProjects.
Add the dfu module to your project:
Add '..:DFULibrary:dfu' to the settings.gradle file: include ':app', '..:DFULibrary:dfu'
Open Project Structure -> Modules -> app -> Dependencies tab and add dfu module dependency. You may also edit the build.gradle file in your app module manually by adding the following dependency: compile project(':..:DFULibrary:dfu')
But I can't find the DFULibrary folder in this project .
Add in your build.gradle
dependencies {
compile 'no.nordicsemi.android:dfu:1.0.4'
}
I started using it today. It is a bit different.
Use menu File -> Project Structure -> Modules.
Click to choose library dependency
Search the library that you want to add in your project and click on to import.
dependencies {
compile "com.android.support:appcompat-v7:28.0.0"
}
Hope this will help you enough.
Go to http://gradleplease.appspot.com/ and search for the library you want.
Go to build.gradle file and add it under dependencies{...} module and add that line and hit the sync button
dependencies {
compile 'no.nordicsemi.android:dfu:0.6'
}

Get the issue with import external library in Android Studio

I want to import the library https://github.com/jpardogo/FlabbyListView
First, I download the Zip file, then I extract it then I copy it to the lib folder of my project, then I turn on my project in Android Stduio. I add this line in the build.gradle compile 'com.jpardogo.flabbylistview:library:(latest version)'. But the Android Studio show:
How can I fix it?
You are mixing two concepts. If you use the compile dependency you don't have to put the jar in libs, and if you put the jar, don't put the managed dependency.
What the line compile library:artifact:version does is putting in your classpath in compile time the corresponding library, downloading it for you from a maven repository.
That said, I suggest you to remove the .jar and change your line of compile to:
compile 'com.jpardogo.flabbylistview:library:1.0.0
if you are manually adding the library to android. then you will add it to you project also.
In you settings.gradle file for the project add
include ':nameoflibrary'
or
include 'lib:nameoflibrary'
Where lib is the name of the folder you added the library and nameoflibrary is the actual name of the library.
then in you actual module usually the app-module gradle file add
dependencies {
compile project(':nameoflibrary')
}
or
dependencies {
compile project('lib:nameoflibrary')
}
same analogy too.
But if you are adding it from the repository you only need to add this line of code in your app-module gradle
dependencies {
compile 'com.jpardogo.flabbylistview:library:(latest version)'
}

Adding external library in Android studio

I want to add external library https://github.com/foursquare/foursquare-android-oauth to my Android application (I use Android Studio, the instructions provided by lib author for Eclipse didn't work for Android Studio).
I've tried to do it with maven, so in File->Project Structure->Dependencies I've added com.foursquare:foursquare-android-nativeoauth-lib:1.0.0 but Gradle Sync fails:
Error:Failed to find: com.foursquare:foursquare-android-nativeoauth-lib:1.0.0
When I try to build my app (without fixing above error becaus I don't know how) I get:
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.foursquare:foursquare-android-nativeoauth-lib:1.0.0.
Required by:
ForSquaresOnly:app:unspecified
> Could not parse POM http://jcenter.bintray.com/com/foursquare/foursquare-android-nativeoauth-lib/1.0.0/foursquare-android-nativeoauth-lib-1.0.0.pom
> Could not find any version that matches com.foursquare:parent:1.0.0.
Any other way to import this lib? I can simply copy-paste source code into my source or create JAR out of it?
BTW: if you run into problems see this question (I had this issue after importing): Manifest merger failed : uses-sdk:minSdkVersion 14
Try one of these approaches:
Approach 1)
1- Choose project view
2- Copy your JAR file in app -> lib folder
3- Right click on your JAR file and choose add as library
4- Check it in build.gradle
Approach 2)
1- File -> New -> New Module
2- Import .JAR/.AAR Package
3- Browse your JAR File
4- Finish
5- File -> Project Structure -> Dependencies
6- You should click on + button and then click on Module Dependency
7- You will see your library here
8- choose your library and click ok
9- Then, you will see that your library is added.
For first two approaches, you need a JAR file. You can search http://search.maven.org/ to find JAR files that are related to Android. For example, this is the search result for jdom in this link
Approach 3) Android is using http://jcenter.bintray.com/ as remote library. For example, this is the search result for jdom in the link.
To add a library in this approach, please follow these steps:
1- File -> Project Structure -> Dependencies
2- Click on + button and choose library dependency
3- find your library and select it, then click OK.
Try this:
File > Project Structure > Dependencies Tab > Add module dependency (scope = compile)
Where the module dependency is the project library Android folder.
To reference an external lib project without copy, just do this:
- Insert this 2 lines on setting.gradle:
include ':your-lib-name'
project(':your-lib-name').projectDir = new File('/path-to-your-lib/your-lib-name)
Insert this line on on dependencies part of build.gradle file:
compile project(':your-lib-name')
Sync project
There are two simplest ways if one does not work please try the other one.
Add dependency of the library inside dependency inside build.gradle file of the library you are using, and paste your library in External Libraries.
OR
Just Go to your libs folder inside app folder and paste all your .jar e.g Library files there, Now the trick here is that now go inside settings.gradle file now add this line include ':app:libs' after include ':app' it will definitely work.
Any other way to import this lib? I can simply copy-paste source code
into my source or create JAR out of it?
Complete Steps for importing a library in Android Studio 1.1
Goto File -> Import Module.
Source Directory -> Browse the project path.
Specify the Module Name
Open build.gradle (Module:app) file
Add the following line with your module name
compile project(':internal_project_name')
Taken from: how to add library in Android Studio
I had also faced this problem. Those time I followed some steps like:
File > New > Import module > select your library_project. Then include 'library_project' will be added in settings.gradle file.
File > Project Structure > App > Dependencies Tab > select library_project. If library_project not displaying then, Click on + button then select your library_project.
Clean and build your project. The following lines will be added in your app module build.gradle (hint: this is not the one where classpath is defined).
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library_project')
}
If these lines are not present, you must add them manually and clean and rebuild your project again (Ctrl + F9).
A folder named library_project will be created in your app folder.
If any icon or task merging error is created, go to AndroidManifest file and add <application tools:replace="icon,label,theme">
A late answer, although I thought of giving an in-depth answer to this question. This method is suitable for Android Studio 1.0.0 and above.
STEPS
First switch your folder structure from Android to Project.
Now search for the libs folder inside app - build folder.
Once you have pasted the .jar file inside libs folder. Right click on the jar file and at end click on Add as library. This will take care of adding compile files('libs/library_name.jar') in build.gradle [You don't have to manually enter this in your build file].
Now you can start using the library in your project.
For the simplest way just follow these steps
Go to File -> New -> Import Module -> choose library or project folder
Add library to include section in settings.gradle file and sync the project (After that you can see new folder with library name is added in project structure)
include ':mylibraryName'
Go to File -> Project Structure -> app -> dependency tab -> click on plus button
Select module dependency -> select library (your library name should appear there) and put scope (compile or implementation)
Add this line in build.gradle in app level module in dependency section
implementation project(':mylibraryName')
Three ways in android studio for adding a external library.
if you want to add libarary project dependency in your project :
A. In file menu click new and choose import module choose your library project path and click ok, library project automatically add in your android studio project .
B. Now open your main module(like app) gradle file and add project dependency in dependency section dependencies {
compile project(':library project name')
if you want to add jar file :
A. add jar file in libs folder.
B. And Add dependency
compile fileTree(dir: 'libs', include: '*.jar') // add all jar file from libs folder, if you want to add particular jar from libs add below dependency.
compile files('libs/abc.jar')
Add Dependency from url (recommended). like
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
Android studio doesn't use Maven, it use Gradle, you can open your build.gradle the route should be: /app/build.gradle and add the Gradle dependency that shows on the repo:
The build.gradle has a dependencies section:
dependencies {
//here add your dependency
}
The repo says that you need to add this dependency:
compile 'com.foursquare:foursquare-android-oauth:1.0.3'
only add that line to your dependencies on buil.gradle, save the file, and android will rebuild the project, that's all
If the library you need is on GitHub then adding it to Android Studio is easy with JitPack.
Step 1. Add the jitpack repository to build.gradle:
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
Step 2. Add the GitHub repository as a dependency:
dependencies {
// ...
compile 'com.github.Username:LibraryRepo:ReleaseTag'
}
JitPack acts as a maven repository and can be used much like Maven Central. The nice thing is that the maintainers don't have to upload the library. Behind the scenes JitPack will check out the code from GitHub and compile it. Therefore for this to work there needs to be a working build file in the git repository.
There is also a guide on how to publish an Android library.
Turn any github project into a single line gradle implementation with this website
https://jitpack.io/
Example, I needed this project:
https://github.com/mik3y/usb-serial-for-android
All I did was paste this into my gradle file:
implementation 'com.github.mik3y:usb-serial-for-android:master-SNAPSHOT'
There are some changes in new gradle 4.1
instead of compile we should use implementation
implementation 'com.android.support:appcompat-v7:26.0.0'
1.Goto File -> New -> Import Module
2.Source Directory -> Browse the project path.
3.Specify the Module Name – it is used for internal project reference.
Open build.gradle (Module:app) file.
implementation project(':library')
I had the same problem. This happened because of core library dependency. I was using javax.* . This is what i did to fix
In File->Project Structure->Dependencies I added this as as provided file, not a compile. Then re build the project.
This problem started after upgrade of android studio. But I think it happens when you try to edit you build files manually.
Adding library in Android studio 2.1
Just Go to project -> then it has some android,package ,test ,project view
Just change it to Project View
under the app->lib folder you can directly copy paste the lib and do android synchronize it.
That's it
1)just get your lib from here http://search.maven.org/
2)create a libs folder in app directory
3)paste ur library there
4)right click on ur library and click "Add as Library"
5)thats all u need to do!
I hope this will definitely gonna help you!!!!
Could not find any version that matches com.foursquare:parent:1.0.0.
Means that library developer made a mistake in .pom file and specified a wrong one.
I would recommend use the standard approach. You can find .pom file in Maven Repository and use that version or ask developer to take a loot at this problem(via github issue tracker)
compile 'com.foursquare:foursquare-android-oauth:1.1.1'
SIMPLE STEPS TO ADD ANY LIBRARY IN ANDROID STUDIO:
Copy the file in question from any folder in your computer (eg. C:/documents/xyz.jar"), then go to Android Studio and right-click the Project Library folder and select paste.
Now, right click on the newly added Library file and select the option "add as Library"
D.O.N.E

Add Caldroid library in Android Studio

I have a problem when adding Caldroid library on Android Studio. I try many different ways to add but it won't work. I use Android Studio 0.8.2.
First off, I created a root folder called libraries.
I created a new folder caldroid in /libraries.
Then, I pasted the downloaded files in /libraries folder.
Then, I changed the following files.
settings.gradle
include ':app'
include 'libraries:caldroid:library'
build.gradle
dependencies {
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:4.0.30'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:caldroid:library')
}
But I get this error:
Error:Configuration with name 'default' not found.
How to fix this?
I'm late but I faced a similar issue so I thought I'll share how I solved it.
To import an external library to Android Studio, I follow this convention:
Create libs folder inside the app directory. Then copy the required library files to the libs folder. For example, my folder contains actionbarsherlock and caldroid folders.
Caldroid has a library dependency that can be downloaded here, you can see this in the build.gradle file (Also, make sure the gradle files have the correct SDK versions). Download the hirondelle-date4j-1.5.1-sources.jar.
Create libs folder in app/libs/caldroid/. Copy the hirondelle-date4j-1.5.1-sources.jar to app/libs/caldroid/libs/. You may also have to copy android-support-v4.jar from -User_Home-/Android/Sdk/extras/android/support/v4/ to app/libs/caldroid/libs/.
Open app/libs/caldroid/build.gradle and replace compile 'com.darwinsys:hirondelle-date4j:1.5.1' with compile files('libs/hirondelle-date4j-1.5.1-sources.jar').
In Android Studio, open settings.gradle and add this line include ':app:libs:caldroid'. Next, open "build.gradle (Module: app)" and add this line compile project(':app:libs:caldroid') in dependencies.
And that's it, now allow the gradle to "sync" or clean and build your project.
Add this line in your dependencies in build.gradle
compile 'com.roomorama:caldroid:3.0.1'

importing ShowcaseView with gradle

I'm trying to use the ShowcaseView project in my app but can't get the project to build.
when I run 'gradle clean installDebug' I get the following error:
A problem occurred evaluating root project 'hows-it-going'.
Could not find method compile() for arguments [project ':ShowcaseView'] on root project 'hows-it-going'.
I'm using gradle 1.11 and Android Studio 0.54.
I've downloaded the source, and imported the project using file -> Import module -> ShowcaseView
which makes my project structure like:
-project
--app
--ShowcaseView
my settings.gradle file looks like:
include ':app', 'ShowcaseView'
and in my project level build.gradle I have the following:
dependencies {
compile project (':ShowcaseView')
}
Any help with how to include this properly would be much appreciated. Thanks.
The latest version of ShowcaseView is available as a .AAR dependency. To use it, add:
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
To your build.gradle file and, under the dependencies block, add:
compile 'com.github.amlcurran.showcaseview:library:5.0.0-SNAPSHOT'
I'll get a stable, non-snapshot, version out soon.
It should actually be
compile 'com.github.amlcurran.showcaseview:library:5.0.0-SNAPSHOT#aar'
That way Maven will use .AAR file
I recently just added ShowcaseView to an Android Studio project, and I hope this can push you in the correct direction.
My file structure looks something like this:
project
app
build.gradle
libraries
showcase
build.gradle
settings.gradle
Add the files from the library
folder
of ShowcaseView to the showcase directory in the libraries
directory.
Add the showcase directory as a module to your project.
Change your app's build.gradle file to include:
dependencies {
compile project(':libraries:showcase')
}
Change your settings.gradle to include:
include ':libraries:showcase'
Sync Project with gradle files
This StackOverflow answer goes over how to do this is much more detail if you have any troubles, but this method works for any library.
The compile dependency on ShowcaseView should likely be defined in app/build.gradle, not in the root project's build.gradle. Unless a project explicitly (configurations block) or implicitly (by applying a plugin such as java) defines a compile configuration, it won't have one, and an attempt to add a compile dependency will result in the error you mentioned.
I added this in build.gradle and it worked
compile 'com.github.amlcurran.showcaseview:library:5.4.3'

Categories

Resources