![](/img/trans.png)
[英]Could not set unknown property 'enableR8' for object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension
[英]Could not get unknown property 'url' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension
我正在尝试从 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'
}
模块 Gradle
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
}
您还必须在 gradle 属性中设置 Api 配置。 希望它能解决问题。
我不得不在BuildConfig.java中生成Url,并且其中提到的方法不起作用。所以我应用了另一种buildconfig方法并且它起作用了。
如此简单,只需 go 到您的 gradle.properties 并与您的 api 创建一条线
样本:
Myapitoken=a9s87d9a798fd79f7d96
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.