无法获得未知的属性“ URL”用于com.android.android.build.gradle.internal.dsl.baseappmoduleextension的Android'

我正在尝试从 Git 集线器制作项目,在导入后它运行良好。但现在在我的另一个项目中使用相同的代码出现了 gradle 同步错误:

无法为 com.android.build.gradle.internal.dsl.BaseAppModuleExtension 类型的扩展“android”获取未知属性“url”

我的应用级别 gradle

  apply plugin: 'com.android.application'

android {
compileSdkVersion 29
defaultConfig {
    applicationId "com.sauravsaidevwhats.whatsappstatussaver"
    minSdkVersion 21
    targetSdkVersion 29
    versionCode 7
    versionName "1.7"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

buildTypes.each {
    it.buildConfigField 'String', 'url', url
    it.buildConfigField 'String', 'url_second', url_second
    it.buildConfigField 'String', 'downloadUrl', downloadUrl
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
     }

   dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'com.github.castorflex.smoothprogressbar:library:1.1.0'
implementation 'commons-io:commons-io:2.4'
implementation 'com.google.android.exoplayer:exoplayer:2.11.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.karumi:dexter:6.0.2'
implementation 'androidx.multidex:multidex:2.0.1'
testImplementation 'junit:junit:4.12'
implementation 'org.jetbrains:annotations:15.0'
}

模块摇篮

   buildscript {
repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.6.2'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
   }

  allprojects {
repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url "https://maven.google.com" }
    maven { url 'https://dl.bintray.com/drummer-aidan/maven' }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
  }

 task clean(type: Delete) {
delete rootProject.buildDir
 }
stack overflow Could not get unknown property 'url' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension
原文答案

答案:

作者头像

转到您的 gradle.properties 并使用API创建一行。例子:

Myapitoken=a9s87d9a798fd79f7d96

相关问题