anko icon indicating copy to clipboard operation
anko copied to clipboard

Toasts, doAsync{}, and uiThread, function calls no longer work with Android studio 3.3

Open ozzy4654 opened this issue 6 years ago • 5 comments

gradle-4.9-all.zip classpath 'com.android.tools.build:gradle:3.3.0-alpha06'

doAsync{}/uiThread{} Cannot access class 'Ljava.util.concurrent.Future;'. Check your module classpath for missing or conflicting dependencies Cannot access class 'Lkotlin.Function1;'. Check your module classpath for missing or conflicting dependencies Type inference failed: fun <T> T.doAsync(exceptionHandler: Function1;<Throwable, Unit>? = ..., task: Function1;<AnkoAsyncContext;<T>, Unit>): Future;<Unit>

Toasts:

Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public inline fun Fragment;.toast(message: CharSequence): Toast; defined in org.jetbrains.anko public inline fun Fragment;.toast(message: Int): Toast; defined in org.jetbrains.anko public inline fun Context;.toast(message: CharSequence): Toast; defined in org.jetbrains.anko public inline fun Context;.toast(message: Int): Toast; defined in org.jetbrains.anko public inline fun AnkoContext;<>.toast(message: CharSequence): Toast; defined in org.jetbrains.anko public inline fun AnkoContext;<>.toast(message: Int): Toast; defined in org.jetbrains.anko

Task :commons-android:compileDebugKotlin FAILED

ozzy4654 avatar Aug 18 '18 18:08 ozzy4654

I had the same problem, and after going crazy for hours, the only solution I found was to use android studio 3.2 and use the following configuration:

Android studio 3.2

KOTLIN PLUGIN: Version: 1.2.60-release-Studio3.2-1

Android studio preferences --> Kotlin compiler LANGUAGE VERSION: 1.2 API VERSION: 1.2

build.gradle (project)

buildscript {
    ext.kotlin_version = '1.2.60'
    ext.anko_version='0.10.5'
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha05'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

build.gradle (Module: App)

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "androidx.lifecycle:lifecycle-extensions:2.0.0-rc01"
    kapt "androidx.lifecycle:lifecycle-compiler:2.0.0-rc01"
    implementation "org.jetbrains.anko:anko:$anko_version"
    implementation "org.jetbrains.anko:anko-coroutines:$anko_version"
    ...more.....

gradle.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

EmmanuelGuther avatar Aug 20 '18 17:08 EmmanuelGuther

If you're comfortable with Canary builds, you can still use Android Studio 3.3 Canary Build 5. The errors occur when using the Canary Build 6 and Gradle Alpha 6.

Also experiencing the same problem. IDE was throwing some errors though I haven't really changed my code, except for the necesaarybuild.gradle to match Gradle dependencies (Alpha 6).

To add, Context.alert functions to do not seem to work as well.

erniealice avatar Aug 21 '18 15:08 erniealice

Same error...

OleksiiAndroid avatar Aug 22 '18 08:08 OleksiiAndroid

I fixed it by downgrading my build.grade dependencies to 'com.android.tools.build:gradle:3.2.0-rc01'

geertberkers avatar Aug 24 '18 09:08 geertberkers

Yeah Iam at Android Studio 3.4 and still they havent found a sloution to this issue its driving me crazy.Still doAsync and uiThread dont work.

incrypto32 avatar Jul 27 '19 17:07 incrypto32