Android Gradle issue?



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

build.gradle(modules:app(

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

格拉德尔项目

// 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 Plugin Version"和"Gradle Version"。确保前者像它应该的那样处于 3.5.1,或者更改它直到它(或更高版本(。您也可以更改第二个("Gradle 版本"(,但我不知道该怎么做。我的在 5.4.1。

更新

在顶级gradle文件中添加谷歌maven

存储库
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }       
google()
}
}

  1. 清洁项目

然后

  1. 打开安卓工作室
  2. 单击文件(在顶部栏中(
  3. 使缓存失效并重新启动
  4. 再次使缓存失效并重新启动

试试这个(您在应用级 gradle 文件中错过了很多内容(

android {
compileSdkVersion 29
defaultConfig {
applicationId "com.App"
minSdkVersion 11
targetSdkVersion 29
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}

并且您的实现文件(库(可能已过时,请尝试更新它或使用 maven 存储库而不是 jar 文件

您可能需要使用旧的Android Studio版本。

最新更新