Android Studio Latest Kotlin/Grade build issue
RingoMckraken opened this issue · comments
Just recently updated to an android studio project to gradle:3.3.0-alpha06 and kotlin version 1.2.61 and there seems to be an issue with the spanner library getting the following error:
Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class lt.neworld.spanner.Spanner;, unresolved supertypes: Landroid.text.SpannableStringBuilder;
And this error everywhere that I'm using Spanner():
Cannot access class 'Llt.neworld.spanner.Spanner;'. Check your module classpath for missing or conflicting dependencies
Also going to file an issue with Android Studio and Kotlin team, just wanted to cover my bases here too.
It is very interesting. Description of the error says there is no Android SDK dependency. Could you give an output of gradle? And, if possible, could you show a reproduction?
Sure Thing
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
//Apply Safe Args Plugin
apply plugin: 'androidx.navigation.safeargs'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.redacted.app"
minSdkVersion 22
targetSdkVersion 28
versionCode 107
versionName "1.07"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion = '28.0.2'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"
implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0-rc01'
implementation 'com.google.android.material:material:1.0.0-rc01'
// Fire base services
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-firestore:17.1.0'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-storage:16.0.1'
// Android KTX
implementation 'androidx.core:core-ktx:1.0.0-rc01'
implementation 'androidx.fragment:fragment-ktx:1.0.0-rc01'
// Life cycles, LiveData, and ViewModel
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-rc01'
kapt "androidx.lifecycle:lifecycle-compiler:2.0.0-rc01"
// Navigation Arch Components
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha05'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha05'
// fuel idiomatic kotlin http lib
implementation 'com.github.kittinunf.fuel:fuel-android:1.15.0' //for Android
implementation 'com.github.kittinunf.fuel:fuel-gson:1.15.0' //for Gson support
// kotlin extensions for gson
implementation 'com.github.salomonbrys.kotson:kotson:2.5.0'
// groupie: better recycler_list views
implementation 'com.xwray:groupie:2.1.0'
implementation 'com.xwray:groupie-kotlin-android-extensions:2.1.0'
// - with data binding
implementation 'com.xwray:groupie-databinding:2.1.0'
// co routines enabled
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.24.0'
// Paper data base for local storage
implementation 'io.paperdb:paperdb:2.6'
// Material dialogue library from github
implementation 'com.afollestad.material-dialogs:commons:0.9.6.0'
// Joda Time
implementation 'joda-time:joda-time:2.10'
// Glide Image Lib
implementation 'com.github.bumptech.glide:glide:4.7.1'
kapt 'com.github.bumptech.glide:compiler:4.7.1'
// Spanner for text formatting programmatically
implementation 'lt.neworld:spanner:0.5.0'
// Process Phoenix for reliable task affinity restarts
implementation 'com.jakewharton:process-phoenix:2.0.0'
// Circle Image View For Contact Cards
implementation 'de.hdodenhof:circleimageview:2.2.0'
// Test
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
androidExtensions {
experimental = true
}
kotlin {
experimental {
coroutines "enable"
}
}
apply plugin: 'com.google.gms.google-services'
The strange thing is that it now grays out my kotlin imports for the Spanner class
When using autocomplete it suggests to import it with a weird java esque escaped version of the import like this:
import lt.neworld.spanner.Spanner;
Seems to be only happening on the Span and Spanner library classes.
Full Error Output:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun <T : kotlin.text.Appendable /* = java.lang.Appendable */> ???.append(vararg value: CharSequence?): ??? defined in kotlin.text
public fun kotlin.text.StringBuilder /* = java.lang.StringBuilder */.append(vararg value: Any?): kotlin.text.StringBuilder /* = java.lang.StringBuilder */ defined in kotlin.text
public fun kotlin.text.StringBuilder /* = java.lang.StringBuilder */.append(vararg value: String?): kotlin.text.StringBuilder /* = java.lang.StringBuilder */ defined in kotlin.text
One last thing, had you tried to build using CLI?
I sure did, gave the same issue, google just released a new patch for android studio canary today so about to test to see if it resolved there. Will post results.
It appears to be fixed! Phew! This android x migration stuff is becoming painful haha!
Glad to hear it :)