错误:无法解决:com.squareup.sdk

时间:2019-03-23 00:47:56

标签: android android-gradle square

因此,我试图通过android studio设置Square Reader SDK,并且在尝试完成“配置构建依赖项”中的第3步时遇到了此错误。

我正在浏览https://docs.connect.squareup.com/payments/readersdk/build-on-android#step-2-configure-your-android-project-for-reader-sdk上的Square Reader SDK文档

我的应用级build.gradle文件供参考:

    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'

任何帮助将不胜感激。

编辑:我遇到了一个新错误:

    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

3 个答案:

答案 0 :(得分:1)

Repro

您的应用程序级别build.gradle似乎不在Square存储库中查找Reader SDK工件。

我从the Square repository中删除了Reader SDK Quick Start Sample Android App,并得到了相同的错误。

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

修复

在应用级android {}文件的dependencies {}build.gradle块之间,添加Square存储库。

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 {
  // ...
}

答案 1 :(得分:0)

就我而言,是解决问题的版本号。 Reader SDK的官方文档目前建议使用版本号“ 1.4.2” ,即使使用上述修复程序,我在配置依赖项时也遇到了相同的错误。

我最终使用我的Reader SDK凭据登录了https://sdk.squareup.com/android,并在com / squareup / sdk / reader / reader-sdk-SQUARE_READER_SDK_APPLICATION_ID下查找了版本号。

事实证明,我发现的唯一可用版本是 1.4.3

因此,如果您的版本号不匹配,只需将build.gradle文件中的版本号更改为您在链接中找到的任何版本。

答案 2 :(得分:0)

以上答案对我不起作用。

当我下载位于here的示例应用程序时,它的实际版本号定义为:

def readerSdkVersion = "1.4.+"

将其从文档定义的1.4.2切换为正常工作,因此我认为这是Square的某个版本控制问题。