Amr Sakr
Amr Sakr

Reputation: 68

java.lang.IllegalStateException: Function not found androidx.compose.internal.restartableFunctionInstance

When I'am trying to run the app I getting the following error

"java.lang.IllegalStateException: Function not found androidx.compose.internal.restartableFunctionInstance"

and the following warning:

C:\Users\amr\.gradle\caches\transforms-2\files-2.1\29795ea219aedbe5401209deaa0aa414\jetified-kotlin-stdlib-jdk7-1.3.60-eap-25.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4

Here is my code in the activity:

class MainActivity: AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle ? ) {
        super.onCreate(savedInstanceState)
        setContent {
            Text("Hello World")
        }
    }
}

I am using android studio 4.2 canary 2

Here is the full build.gradle file"

 apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'

    android {
      compileSdkVersion 28

      defaultConfig {
        applicationId "com.example.myfirstCompse"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      }

      buildTypes {
        release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
      }

      buildFeatures {
        compose true
      }



      compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
      }

      kotlinOptions {
        jvmTarget = "1.8"
      }

 composeOptions {
        kotlinCompilerExtensionVersion "0.1.0-dev09"
    }

    }

    dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
      implementation 'androidx.appcompat:appcompat:1.1.0'
      implementation 'androidx.core:core-ktx:1.1.0'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'androidx.test.ext:junit:1.1.1'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

      implementation 'androidx.ui:ui-framework:0.1.0-dev09'
    implementation 'androidx.ui:ui-tooling:0.1.0-dev09'
    implementation 'androidx.ui:ui-layout:0.1.0-dev09'
    implementation 'androidx.ui:ui-material:0.1.0-dev09'


    }

Update: when I change the dependency version to dev09, and added compileOptions block as the documentation suggests

composeOptions {
        kotlinCompilerExtensionVersion "0.1.0-dev09"
    }

it produced the following error:

e: java.util.NoSuchElementException: Collection contains no element matching the predicate.

Upvotes: 3

Views: 1543

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007339

Add kotlinCompilerVersion = "1.3.70-dev-withExperimentalGoogleExtensions-20200424" to your composeOptions closure:

composeOptions {
    kotlinCompilerVersion = "1.3.70-dev-withExperimentalGoogleExtensions-20200424"
    kotlinCompilerExtensionVersion "0.1.0-dev09"
}

You definitely need this; I am uncertain if it will clear up this specific error.

You may wish to check the version of Kotlin that you are using in your project-level build.gradle file. 1.3.70 is a known safe version (it matches the compiler plugin version from my code snippet).

Upvotes: 3

Related Questions