找不到对象上参数 [com.android.support:appcompat-v7:25.4.0] 的方法实现().人



我必须编译一个在线购买的项目。将其导入安卓工作室时..它抱怨 gradle 版本,所以我将 distributionUrl 更新为此distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip

当我现在尝试清理项目并重建时。它失败并出现此错误:

错误:(45, 1)评估项目":app"时出现问题。 在类型为 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 的对象上找不到参数 [com.android.support:appcompat-v7:25.4.0] 的方法实现()。

以下是整个构建 gradle 文件:

 apply plugin: 'com.android.application'
 apply plugin: 'io.fabric'
 android {
   compileSdkVersion 25
   buildToolsVersion '26.0.0'
   defaultConfig {
    applicationId "dumm.value"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 5
    versionName "1.0.4"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
 }
 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
 }

  dependencies {
   compile fileTree(include: ['*.jar'], dir: 'libs')
   androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'
})
/* Remove This to remove Crashlytics and Fabric */
  compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
    transitive = true;
  }
/*    compile('com.digits.sdk.android:digits:2.0.6@aar') {
    transitive = true;
  }*/
  implementation 'com.android.support:appcompat-v7:25.4.0'
  implementation 'com.android.support:design:25.4.0'
  implementation 'com.android.support:recyclerview-v7:25.4.0'
  implementation 'com.squareup.okhttp3:okhttp:3.8.1'
  implementation 'com.android.support:cardview-v7:25.4.0'
  implementation 'com.github.bumptech.glide:glide:3.8.0'
  implementation 'com.google.android.gms:play-services-maps:11.0.2'
  implementation 'com.google.android.gms:play-services-location:11.0.2'
  implementation 'com.google.android.gms:play-services-places:11.0.2'
  implementation 'com.google.firebase:firebase-auth:11.0.2'
  implementation 'com.google.firebase:firebase-messaging:11.0.2'
  implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
  implementation 'com.google.code.gson:gson:2.8.0'
  testCompile 'junit:junit:4.12'

 }
 apply plugin: 'com.google.gms.google-services'

请问我该如何解决这个问题?

要使用implementation()您需要使用 gradle v.4 和 gradle 插件 v.3

用:

distributionUrl=
  https://services.gradle.org/distributions/gradle-4.1-all.zip

buildscript {
    repositories {
        ...
        // You need to add the following repository to download the
        // new plugin.
        maven {
            url "https://maven.google.com"
        }            
        //google()  //only if you use Android Studio 3.x
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta7'
    }
}

更多信息在这里。

1.打开应用程序的 build.gradle 文件。2.确保存储库部分包含具有"https://maven.google.com"端点的 maven 部分。例如:

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

就我而言,我发现在app.gradle文件中

实现Sdk版本27

在那里而不是

编译Sdk版本27

所以把它放下面

 compileSdkVersion 28
defaultConfig {
    applicationId "com.kotlinpractise"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
如果您

仍然收到错误,请尝试更改软件包的android/build.gradle,node_modules从实现到编译。为我工作。可以在项目文件夹中使用以下命令。

sed -i -s "s#implementation#compile#" node_modules/your-react-native-package-name/android/build.gradle

最新更新