ОШИБКА: не удалось найти репозиторий методов () при использовании OneDrive SDK - PullRequest
0 голосов
/ 11 марта 2019

Я пытаюсь использовать OneDrive SDK, следуя инструкциям, показанным здесь . К сожалению, я не могу выполнить синхронизацию проекта Gradle, когда добавляю зависимости, показанные в руководстве по установке SDK. Я получаю следующее сообщение об ошибке:

ERROR: Could not find method repository() for arguments [build_xqhe0znpcz2uhmxa019kwrtr$_run_closure2@18623fec] on project ':app' of type org.gradle.api.Project.

Пожалуйста, кто-нибудь может помочь мне определить проблему? Мой build.gradle файл выглядит так:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.onedrivesdkapp"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

repository {
    jcenter()
}

dependency {
    // Include the sdk as a dependency
    compile ('com.onedrive.sdk:onedrive-sdk-android:1.3+') {
        transitive = false
    }

    // Include the gson dependency
    compile ('com.google.code.gson:gson:2.3.1')

    // Include supported authentication methods for your application
    compile ('com.microsoft.services.msa:msa-auth:0.8.+')
    compile ('com.microsoft.aad:adal:1.1.+')
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

1 Ответ

1 голос
/ 12 марта 2019

Кажется, что onedrive-sdk-android библиотека больше не поддерживается, потому что последняя фиксация произошла 2 года назад.

Проблема: Ваш код для импорта зависимостей неверен, поэтому Gradle выдает ошибку.

Решение: Выполните следующие шаги.

Шаг 1: Удалите следующую строку из файла Gradle

repository {
    jcenter()
}

dependency {
    // Include the sdk as a dependency
    compile ('com.onedrive.sdk:onedrive-sdk-android:1.3+') {
        transitive = false
    }

    // Include the gson dependency
    compile ('com.google.code.gson:gson:2.3.1')

    // Include supported authentication methods for your application
    compile ('com.microsoft.services.msa:msa-auth:0.8.+')
    compile ('com.microsoft.aad:adal:1.1.+')
}

Шаг 2: Переместить строку всех зависимостей в блок dependencies.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    // Include the sdk as a dependency
    implementation ('com.onedrive.sdk:onedrive-sdk-android:1.3+') {
        transitive = false
    }

    // Include the gson dependency
    implementation ('com.google.code.gson:gson:2.3.1')

    // Include supported authentication methods for your application
    implementation ('com.microsoft.services.msa:msa-auth:0.8.+')
    implementation ('com.microsoft.aad:adal:1.1.+')
}

Соберите все вместе, ваш файл Gradle будет выглядеть как

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.onedrivesdkapp"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    // Include the sdk as a dependency
    implementation ('com.onedrive.sdk:onedrive-sdk-android:1.3+') {
        transitive = false
    }

    // Include the gson dependency
    implementation ('com.google.code.gson:gson:2.3.1')

    // Include supported authentication methods for your application
    implementation ('com.microsoft.services.msa:msa-auth:0.8.+')
    implementation ('com.microsoft.aad:adal:1.1.+')
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...