Android Gradle 问题?

标签 android android-studio gradle

我在Android Studio(最新的Android Studio版本)中导入了一个应用程序,我尝试了以下所有操作:卸载并再次安装JDK,重新申请每个库,更新SDK管理器,代码在5-6年前,所以现在我试图更新 Gradle,但我无法解决这个问题。
build.gradle(模块:应用程序)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 16
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "com.App"
        minSdkVersion 11
        targetSdkVersion 29
    }compile

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
    compileSdkVersion = 29
}

dependencies {
    implementation files('libs/asmack-issue-13.jar')
    implementation files('libs/gcm.jar')
    implementation files('libs/gson-1.7.1.jar')
    implementation files('libs/httpmime-4.1-beta1.jar')
    implementation files('libs/mediationsdk-6.4.17.jar')
    implementation files('libs/PayPalAndroidSDK.jar')
}
Gradle-wrapper.propertis
#Mon Jan 27 05:34:23 GST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
项目 Gradle
  // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.1'
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
错误
Total time: 12.797 secs
ERROR: Gradle DSL method not found: 'google()'
Possible causes:
The project 'App_copy' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.5.1 and sync project

The project 'App_copy' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file

The build file may be missing a Gradle plugin.
Apply Gradle plugin

最佳答案

右键单击您的项目,单击“打开模块设置”,然后单击左侧部分中的“项目”。它应该为您提供一些下拉菜单“Android Gradle 插件版本”和“Gradle 版本”。确保前者像应有的那样处于 3.5.1,或者更改它直到它是(或更高版本)。您也可以更改第二个(“Gradle 版本”),但我不知道该怎么做。我的是 5.4.1。

关于Android Gradle 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59924712/

相关文章:

Android 应用程序将仅在 API 25 上运行

android - 谷歌宣布新的 sdk 版本控制系统后 Gradle 项目同步失败

android - 在gradle中重命名apk

java - 使用 Glide Library 时,小尺寸图像会自动调整大小

android - Android 网页 View 中的 ERR_ACCESS_DENIED - 仅适用于 sdk 30

java - 抽屉布局类未找到错误

android-studio - Android Studio 错误 |模拟器 : emulator: ERROR: VkCommonOperations. cpp:496:无法创建 Vulkan 实例

gradle - Artifactory 如何处理发布/快照策略?

android - 多游标加载器

android - 如何使用 toJson 和 fromJson 从 Json 文件中获取对象