With this error : DefaultTaskContainer#register(String, Class, Action) on task set cannot be executed in the current context. No details is shown in the IDE but Android Studio is failing to run the application after getting updated. I am using android studio for developing one of my project. All the sudden the issue occurred.
Here are my gradle files: Project Level :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
google()
jcenter()
// Add repository
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha02'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.firebase:firebase-core:16.0.5'
// Check for v3.1.2 or higher
classpath 'com.google.gms:google-services:4.2.0'
// Add dependency
classpath 'io.fabric.tools:gradle:1.25.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app level :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.bendroidappsn.***"
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
versionCode 24
versionName "APPLE"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
lintOptions {
checkReleaseBuilds false
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-multidex-rules.pro'
}
}
}
ext {
//supportLibraryVersion = '28.0.0-rc01'
supportLibraryVersion = '28.0.0'
playServicesVersion = '17.0.0'
}
dependencies {
implementation "com.google.android.gms:play-services-ads:$playServicesVersion"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha07'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha07'
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha07'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha07'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-firestore:17.1.2'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-config:16.1.0'
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
compile 'com.android.support:multidex:1.0.3'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
//if(!details.equals(com.android.support:multidex)) {
if (!requested.name.startsWith("multidex")) {
details.useVersion "$supportLibraryVersion"
}
}
}
}
repositories {
mavenCentral()
}
Try to set
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
in the file gradle-wrapper.properties
that works for me
I ran into this exact issue after updating to Android Studio 3.4 Canary 4. Disabling instant run fixed it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With