Не удалось найти метод compile () для аргументов [com.android.support:appcompat-v7:25.0.0] - PullRequest
0 голосов
/ 28 октября 2019

Попытка построить собственный собственный проект и не может скомпилировать appcompat

Не удалось найти метод compile () для аргументов [com.android.support:appcompat-v7:25.0.0] на объектетипа org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        compile 'com.android.support:appcompat-v7:25.0.0'
        compile 'com.android.support:support-annotations:25.0.0'
        compile 'com.android.support:design:25.0.0'
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
            url "$rootDir/../node_modules/expo-camera/android/maven"
        }
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.7'
    distributionUrl = distributionUrl.replace("bin", "all")
}

ОБНОВЛЕНИЕ переход к выходам реализации

ERROR: Could not find method implementation() for arguments [com.android.support:appcompat-v7:25.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

Ответы [ 4 ]

1 голос
/ 28 октября 2019

Файл build.gradle верхнего уровня - неподходящее место для зависимостей. Это даже указано в комментарии в вашем коде:

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

Вы должны переместить эти строки в другой файл build.gradle (в вашем модуле)

0 голосов
/ 28 октября 2019

enter image description here Использовать реализацию, а не компилировать. Компиляция теперь запрещена для файла Gradle.

использование реализации против компиляции.

testImplementation use Против testcompile.

runtimeOnly use Against runtime.

 implementation 'com.android.support:appcompat-v7:25.0.0'
    implementation 'com.android.support:support-annotations:25.0.0'
    implementation 'com.android.support:design:25.0.0'

Эти строки не будут введены в build.gradle (Project: Projectname) Эти строки будут находиться под build.gradle (Module: app)

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.waltonbd.myapplication"
        minSdkVersion 15
        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'
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/raw'] } }
}


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'
    implementation 'com.android.support:design:28.0.0'
    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'
}

Еще один build.gradle (Проект: Имя проекта) . Не входите сюда.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
0 голосов
/ 28 октября 2019

Попробуйте заменить compile на implementation:

implementation 'com.android.support:appcompat-v7:25.0.0'
implementation 'com.android.support:support-annotations:25.0.0'
implementation 'com.android.support:design:25.0.0'

Метод compile устарел: https://docs.gradle.org/current/userguide/java_library_plugin.html

Компиляция, testCompile, время выполнения и testRuntimeконфигурации, унаследованные от плагина Java, по-прежнему доступны, но устарели. Вам следует избегать их использования, поскольку они сохраняются только для обратной совместимости.

Возможно, что теперь они фактически удалены из используемой вами версии gradle.

0 голосов
/ 28 октября 2019

Ключевое слово compile в gradle устарело, замените его на implementation.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...