gpt4 book ai didi

android - 找不到参数的方法 compile() [com.android.support :appcompat-v7:25. 0.0]

转载 作者:行者123 更新时间:2023-12-05 00:11:09 26 4
gpt4 key购买 nike

试图构建一个 react 原生项目,并且无法编译 appcompat

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



构建.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")
}

更新
更改为实现 yield
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

最佳答案

enter image description here使用实现而不是编译。
gradle 文件现在不推荐编译。

实现使用反对编译。

testImplementation 使用 反对 testcompile。

runtimeOnly 使用针对运行时。

 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(模块: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
}

关于android - 找不到参数的方法 compile() [com.android.support :appcompat-v7:25. 0.0],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58594801/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com