3

So I'm trying to set up the Square Reader SDK through android studio, and I run across this error when trying to complete the 3rd step in "Configure the build dependencies"

I'm following through the Square Reader SDK docs at https://docs.connect.squareup.com/payments/readersdk/build-on-android#step-2-configure-your-android-project-for-reader-sdk

My app-level build.gradle file for reference:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.cedarrobots.cedarrestaurants3"
        minSdkVersion 21
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        // Ensures incremental builds remain fast
        preDexLibraries true
        // Required to build with Reader SDK
        jumboMode true
        // Required to build with Reader SDK
        keepRuntimeAnnotatedClasses false
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    def readerSdkVersion = "1.2.1"
    implementation "com.squareup.sdk.reader:reader-sdk-$SQUARE_READER_SDK_APPLICATION_ID:$readerSdkVersion"
    runtimeOnly "com.squareup.sdk.reader:reader-sdk-internals:$readerSdkVersion"

    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
    compile 'com.firebaseui:firebase-ui-database:1.1.1'
    compile 'com.google.firebase:firebase-core:16.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    testImplementation 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

Any help would be greatly appreciated.

Edit: I'm getting a new error:

    Error:Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not resolve com.squareup.sdk.reader:reader-sdk-{sq0idp-0alGJZsc2rS5fTIOTkPLsA}:1.2.1.
  Required by:
      project :app
   > Could not resolve com.squareup.sdk.reader:reader-sdk-{sq0idp-0alGJZsc2rS5fTIOTkPLsA}:1.2.1.
      > Could not get resource 'https://sdk.squareup.com/android/com/squareup/sdk/reader/reader-sdk-%7Bsq0idp-0alGJZsc2rS5fTIOTkPLsA%7D/1.2.1/reader-sdk-%7Bsq0idp-0alGJZsc2rS5fTIOTkPLsA%7D-1.2.1.pom'.
         > Could not GET 'https://sdk.squareup.com/android/com/squareup/sdk/reader/reader-sdk-%7Bsq0idp-0alGJZsc2rS5fTIOTkPLsA%7D/1.2.1/reader-sdk-%7Bsq0idp-0alGJZsc2rS5fTIOTkPLsA%7D-1.2.1.pom'. Received status code 401 from server: Unauthorized
defkey123
  • 103
  • 1
  • 10

3 Answers3

1

Repro

It looks like your app-level build.gradle isn't looking in the Square repository for the Reader SDK artifact.

I commented out the Square repository from the Reader SDK Quick Start Sample Android App and got the same error.

ERROR: Failed to resolve: com.squareup.sdk.reader:reader-sdk-...

Fix

Between the android {} and dependencies {} blocks in your app-level build.gradle file, add the Square repository.

android {
 // ...
}

repositories {
  google()
  maven {
    url "https://sdk.squareup.com/android"
    credentials {
      username SQUARE_READER_SDK_APPLICATION_ID
      password SQUARE_READER_SDK_REPOSITORY_PASSWORD
    }
  }
  jcenter()
}

dependencies {
  // ...
}
Community
  • 1
  • 1
Salvatore Testa
  • 317
  • 2
  • 9
0

In my case, it was the version number that did the trick. Official Reader SDK docs are currently suggesting the version number "1.4.2", and I had the same error trying to configure the dependencies, even with the fix above.

I ended up logging in on https://sdk.squareup.com/android with my Reader SDK credentials and looking up the version number under com/squareup/sdk/reader/reader-sdk-SQUARE_READER_SDK_APPLICATION_ID.

As it turns out, the only available version I found was 1.4.3.

So if your version numbers don't match, just change the one in your build.gradle file to whatever version you found in the link.

Bojan Vilic
  • 3
  • 1
  • 3
0

The above answers did not work for me.

When I downloaded their sample app located here, it actually has the version number defined as:

def readerSdkVersion = "1.4.+"

Switching it from the documentation-defined 1.4.2 to that worked just fine so I think it is some versioning issue on Square's end.

PGMacDesign
  • 6,092
  • 8
  • 41
  • 78