Search code examples
android-studiogithubalpha-vantage

How to import alphavantage library in android studio


I want to import this library https://github.com/patriques82/alphavantage4j in android studio. What steps should I follow?(from scratch) Also in which build.gradle should I put repositories and dependencies?

I have an empty project. I downloaded the zip file and extracted it. I then tried to import the module but only the build.gradle file was imported.

There already existed a build.gradle file. So I renamed the build.gradle as builder.gradle and imported it.But it showed error as sync failed.


Solution

  • 1. Create a new Android Project.

    2. Open build.gradle.There will be two gradle builds, you will need to select the Project build

    3. Add the repository information maven{...} to both buildscript and allprojects.

    buildscript {
        ext.kotlin_version = '1.3.31'
        repositories {
            google()
            jcenter()
            maven {
                url  "https://dl.bintray.com/patriques82/maven"
            }
    
        }
    
    allprojects {
        repositories {
            google()
            jcenter()
            maven {
                url  "https://dl.bintray.com/patriques82/maven"
            }
    
        }
    }
    

    4. Open up the second 'build.gradle' (Module:app) and add into dependencies the following

    implementation 'org.patriques:alphavantage4j:1.4'