android - 错误 :Failed to resolve: com. squareup.sdk

标签 android android-gradle-plugin 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

最佳答案

复制

看起来您的应用级 build.gradle 并未在 Square 存储库中查找 Reader SDK Artifact 。

我注释掉了the Square repository来自 Reader SDK Quick Start Sample Android App并得到了同样的错误。

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

修复

在您的应用级 build.gradle 文件中的 android{}dependencies{} block 之间,添加 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 {
  // ...
}

关于android - 错误 :Failed to resolve: com. squareup.sdk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55309543/

相关文章:

android - Square LeakCanary 找不到符号

swift - 如何制作方形视频?

java - 当我运行我的应用程序时出现未知错误

android - 如何调试 Android 样式继承问题?

java - setTitle 不工作 Android

Android Studio 0.4 在 APK META-INF/LICENSE.txt 中复制的重复文件

ios - Square应用是否具有自定义URL方案?

Android:在按钮上使用图像而不是文本

android - 混合版本会导致 Firebase 中的运行时崩溃吗?

android - 更新 Android Studio 3.1 后发布签名 APK 时出错