but when I build it gives me an error
recently android updated for kotlin
and my android gradle vesion is 3.1.2
and kotlin version is 1.2.41
android studio 3.1.2
i'm targeting android p
this is latest version so i can't find more documentation on this problem and
please help me to find out this problem
android issues
Program type already present: android.support.v4.media.MediaBrowserCompat$ConnectionCallback$StubApi21
build.gradle(app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 'android-P'
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.xxxxxxx.xx"
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.anko:anko-commons:0.10.4'
implementation 'androidx.core:core-ktx:1.0.0-alpha1'
implementation "androidx.appcompat:appcompat:1.0.0-alpha1"
implementation "androidx.legacy:legacy-support-v4:1.0.0-alpha1"
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
implementation "com.google.android.material:material:1.0.0-alpha1"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
//firebase massaging
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-core:15.0.2'
def lifecycle_version = "2.0.0-alpha1"
def room_version = "2.0.0-alpha1"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
// room database persistent
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
// optional - Test helpers for LiveData
testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
//data binding
//kapt 'com.android.databinding:compiler:3.1.2'
}
apply plugin: 'com.google.gms.google-services'
please help me what is problem I can't find out
i removed Androidx from my whole project but isue still parsist then
i found solution and replace
implementation 'androidx.core:core-ktx:1.0.0-alpha1'
to
implementation 'androidx.core:core-ktx:0.3'
and my problem is solved.
anyway thanks all second-time I'm going to use androidx (Android + Kotlin)
I'm waiting for jetpack stable version.
Actually this is a bug in Canary 14. You should wait for Canary 15 ;-)
Check out this session.
have you tried downloading android studio 3.2 canary 14? there is a new option to convert your files to androidX and will give you a preview of what it's going to do. Back up your files or at least use git to make sure it's safe.
thanks for the edit paul
Related
After updating my Android Studio Canary version to 3.1, I started receiving Kotlin unresolved references for functions belonging to the kotlin standard library, and the issue also seems to be affecting Android Studio's ability to import the correct library.
I believe my issue is similar to this. Per a recent comment, changing my gradle kotlin version to 1.5.0 fixed the "unresolved reference" issue, but compose beta06 does not support 1.5.0 yet.
I was wondering if anybody had any luck solving this. I believe I have tried to update as many of my dependencies as well as clean building, invalidating cache and restarting.
Here is my gradle file.
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.leetcards"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
useIR = true
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.4.32'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.0-alpha07'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
// Navigation
def nav_version = "1.0.0-alpha10"
implementation "androidx.navigation:navigation-compose:$nav_version"
// Accompanist
def accompanist_version = "0.9.0"
// implementation "com.google.accompanist:accompanist-coil:$accompanist_version"
// Networking (Retrofit and Moshi)
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
def moshi_kotlin_version = "1.12.0"
def moshi_converter_version = "2.9.0"
implementation "com.squareup.moshi:moshi-kotlin:$moshi_kotlin_version"
implementation "com.squareup.retrofit2:converter-moshi:$moshi_converter_version"
// Firebase
implementation platform('com.google.firebase:firebase-bom:27.1.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.firebaseui:firebase-ui-auth:7.1.1'
implementation 'com.facebook.android:facebook-android-sdk:4.x'
// Facebook login
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
// CameraX core library using the camera2 implementation
def camerax_version = "1.0.0"
// The following line is optional, as the core library is included indirectly by camera-camera2
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
// If you want to additionally use the CameraX Lifecycle library
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
// If you want to additionally use the CameraX View class
implementation "androidx.camera:camera-view:1.0.0-alpha24"
}
I too have the same problem with Compose project in Android Studio after upgrade to Kotlin 1.5.0. Unresolved references seem to come from the mismatch between Kotlin version defined in project gradle files and Kotlin version bundled with Kotlin plugin. There is some old thread on SO describing similar issue in IntelliJ: link
Summarizing, there are 2 conflicting situations:
Switching to Kotlin 1.5.0 throws error about Jetpack Compose incompatibility;
Downgrading to Kotlin 1.4.32 allows to compile and install the app, however problem with unresolved references arises. Kotlin plugin cannot be easily downgraded (or can it?).
As a temporary measure I am switching between two Kotlin versions, in hope of finding better solution.
I was following the android lessons on codelabs and they were introducing databinding. According to the code, all i needed to do was to enable databinding within the build.gradle file as below:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.lesson4"
minSdkVersion 18
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
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'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
However, the project fails to build into the emulator, and I am presented with the error code: Unable to load class 'javax.xml.bind.JAXBException'.
I also went further to amend the XML file of activity_main to wrap the ConstraintLayout within a Layout tag, but I think the error is somewhere within the gradle build portion instead.
I have tried various methods, such as apply plugin: 'kotlin-kapt' as well as including the kotlin dependencies, but the same error still persist.
I have also tried cleaning the project and rebuilding it.
I have also tried creating a brand new project, and only enabling databinding... The same error persists.
Hope someone can enlighten me about how to get databinding working in intellij for android?
Upon some research I have found that data binding will throw errors while using Java 9+.
All you have to do is set your Java to version 8 and it should work.
I don't want to use Java 8
Then you have to manually add the JAX-B dependencies
kapt "com.sun.xml.bind:jaxb-core:2.3.0.1"
kapt "javax.xml.bind:jaxb-api:2.3.1"
kapt "com.sun.xml.bind:jaxb-impl:2.3.2"
annotationProcessor "com.sun.xml.bind:jaxb-core:2.3.0.1"
annotationProcessor "javax.xml.bind:jaxb-api:2.3.1"
And apply the kotlin-kapt plugin with:
apply plugin: 'kotlin-kapt'
This question already has answers here:
Android Studio keeps refusing to resolve com.android.support:appcompat-v7:29.0.1
(6 answers)
Closed 3 years ago.
I need to create a recyclerview in Android Studio. I don't know why it keeps saying that it cannot resolve symbol recyclerview. I have done all the step according to those website tutorial.
My app gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:appcompat-v7:29.1.1'
//card view
implementation 'com.android.support:cardview-v7:29.1.1'
//recyclerView
implementation 'com.android.support:recyclerview-v7:29.1.1'
//picasso library to retrive images
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-storage:18.0.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
apply plugin: 'com.google.gms.google-services'
}
May I know what's wrong with my code in the gradle file? Thanks in advance.
Here is my error report in logcat:
you are trying to access the wrong package.
try androidx.recyclerview instead of the legacy android.support.v7.widget.RecyclerView;
you should replace all the com.android.support.* dependencies, and replace with the androidx equivalent. (currently, you have a mix of both androidx and the legacy android.support dependencies)
https://developer.android.com/jetpack/androidx/releases/recyclerview
you can try using the Refactor> Migrate to AndroidX option on Android Studio for the auto fix
replace you recyclerview library with this -> androidx.recyclerview:recyclerview:1.0.0
as you are using the androidx, but your recycler view's library is still in support library format
to get proper migration information do refer to this -> https://developer.android.com/jetpack/androidx/migrate
I recently updated my Android Studio from 2.3.3 to 3.2 but unfortunately it have been two days, that I'm trying to fix bugs but, I resolved the most but I still have some problems that persist in my projects:
The gradle build keep showing me this error about Kotlin version:
The Android Gradle plugin supports only Kotlin Gradle plugin version
1.2.51 and higher. Project 'XXX' is using version 1.1.4-3.
=> The problem is my kotlin is declared as automated update version :
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
I don't know where can I change the version as they mention.
This line code is always underlined in red:
implementation 'com.android.support:appcompat-v7:28.0.0'
The build tool version is 28.0.2
The error declared is:
all com.android.support libraries must use the exact same version specification.
PS: I used 28.0.0 is all com.android.support libraries.
If you have any solutions to this two problems please let me know.
Thank you in advance.
Here is my build file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.firebase.firebase-crash'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "com.ameerhamza6733.directmessagesaveandrepost"
minSdkVersion 17
targetSdkVersion 28
versionCode 32
versionName "1.0.32"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation project(':easy_sharedpreference_library')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'org.jsoup:jsoup:1.10.3'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.lolucosmin:PermissionsWrapper:version_1.2'
implementation 'com.artjimlop:altex-image-downloader:0.0.4'
implementation 'com.daimajia.numberprogressbar:library:1.4#aar'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.webianks.library:easy-feedback:1.0.2'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.android.ads.consent:consent-library:1.0.6'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'
testImplementation 'junit:junit:4.12'
implementation project(':library')
}
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
google()
}
The gradle build keep showing me this error about Kotlin version:
Answer
Open your project level build.gradle file,
there you'll find a block named buildscript.
Go to that block and find if there is a variable named ext.kotlin_version
Change it to your latest version of Kotlin plugin.
all com.android.support libraries must use the exact same version
specification.
Issue for this is that the library you're using easy-feedback is having different version for support library (v25) than you're using (v28).
Solution is to exclude your support library from that dependency like below:
implementation ('com.webianks.library:easy-feedback:1.0.2', {
exclude group: 'com.android.support'
})
Note : If problem still persist, then check it with other 3rd party dependencies too.
I was working with android jetback after add recycle view with androidx and databinding and live datait started showing
android.support.v4.app.INotificationSideChannel$Stub.
I have tried a lot of solutions so far but nothing has helped. Why does it show this error when I am not using any support library and what can I do to solve it?
update :
after retracing my steps i removed the data binding and every thing worked fine can any one explain
Here is my gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.ahmedmubarak.pixeapp"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
implementation 'androidx.cardview:cardview:1.0.0-beta01'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-beta01'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
}
I added this to build.gradle to remove the error
configurations {
implementation {
exclude group: 'com.android.support', module: 'support-v4'
}
}
Unfortunately, I predict that you'll see a new error (at run-time) like this:
java.lang.NoClassDefFoundError: Failed resolution of:
I believe this is an AndroidX issue that occurs with lots of support libraries that have yet to be updated to support AndroidX.
I have a similar problem. In my case, it was because I am using Glide library and androidx. This solution works for me:
Set enableJetifier value to true
Update Gradle build tool to 3.3.0-alpha08 with Gradle version 4.9
source