I'm trying to use the new Navigation Architecture Component for android and I'm getting the error
Failed to resolve: androidx.lifecycle:lifecycle-viewmodel-ktx:1.1.1
when I'm defining the lifecycle_version to "1.1.1"
I'm basically just copying and pasting what is in the documentation so I'm running out of ideas of what is wrong in here :(
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.mobile.codgin.newnavigation"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
def lifecycle_version = "1.1.1"
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
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'
}
try replace
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
with this
//https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-viewmodel-ktx
implementation group: 'androidx.lifecycle', name:'lifecycle-viewmodel-ktx', version: '2.0.0-alpha1'
then sync again.
You can have a look here :
https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-viewmodel-ktx/2.0.0-alpha1
it seems to be that the repository was emptied somehow. Hence, you can not download it from the repository.
When it shows you this error add this code to section build.gradle
configurations {
all {
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
}
}
Related
Why is this Error Getting me While Generating a Signed Apk in Kotlin? Anyone who knows the solution please send an answer.
Logcat Error:
Execution failed for task ':app:lintVitalRelease'.
Lint found fatal errors while assembling a release target.
I'm adding build.gradle file. I don't know what's wrong with my code, So please anyone know solution please answer.
Build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.testing.app"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
implementation "android.arch.persistence.room:runtime:1.1.1"
kapt "android.arch.persistence.room:compiler:1.1.1"
implementation "android.arch.lifecycle:livedata:1.1.1"
kapt "android.arch.lifecycle:compiler:1.1.1"
implementation 'com.karumi:dexter:5.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.anko:anko:$anko_version"
//Anko Commons
implementation "org.jetbrains.anko:anko-commons:$anko_version"
implementation "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version"
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.github.medyo:android-about-page:1.2.2'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
implementation "com.google.firebase:firebase-ml-model-interpreter:17.0.3"
implementation "com.google.firebase:firebase-ml-vision:19.0.2"
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-crash:16.2.1'
}
apply plugin: 'com.google.gms.google-services'
I had this problem and solved it by adding:
lintOptions {
checkReleaseBuilds false
}
to my build.gradle file within the android{ } section.
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
supertypes of the following classes cannot be resolved. please make sure you have the required dependency in the classpath : class com.google.firebase.auth.internal.internalAuthProvider , unresolved supertypes
com.google.firebase.internal.internalTokenProvider
Here is the code:
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.firebaseuiexample"
minSdkVersion 29
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'
}
}
}
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'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.firebaseui:firebase-ui-auth:4.3.2'
}
apply plugin: 'com.google.gms.google-services'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
change to these implementations.
I have an android module (my own lib) which I'm using to fetch data from the web and display it as a list using recyclerview.
The data consists of paths to images which i'm loading via Picasso lib. Each item in the recyclerview list is an ImageView.
I am using androidx dependencies. The apps works as expected when installed in an emulator with API 24. However, the data is not displayed when the app is installed in an emulator with API 28.
I already debugged for API 28 and the data is fetcheda as expected.
Here is where the list returns from the web as 'it'. When debugging, the list comes with 20 items as expected.
viewModel.trendingsLiveData.observe(this, Observer {
Log.d("trendingtitle", "trendingsLiveData.observe() called")
allTrendingAdapter!!.loadItems(it)
allTrendingAdapter!!.notifyDataSetChanged()
shimmerViewContainer?.stopShimmer()//stopShimmerAnimation()
shimmerViewContainer?.setVisibility(View.INVISIBLE)
})
Line used to load images in the adapter (also checked with a breakpoint - working as expected)
Picasso.get().load("http://image.tmdb.org/t/p/w342${results!!.get(position).poster_path}").into(holder.poster);
Build.gradle (my Android Module)
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
buildToolsVersion "29.0.0"
defaultConfig {
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
def moshiVersion="1.8.0"
def retrofit2_version = "2.5.0"
def okhttp3_version = "3.12.0"
def kotlinCoroutineVersion = "1.0.1"
def picassoVersion = "2.71828"
//ViewModel Scope
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha01'
//recyclerview
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
//Moshi
implementation "com.squareup.moshi:moshi-kotlin:$moshiVersion"
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion"
//Retrofit2
implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-moshi:$retrofit2_version"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2"
//Because of an error with JAR version
implementation "org.jetbrains.kotlin:kotlin-reflect:'1.3.31'"
//Okhttp3
implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
//Picasso
implementation ("com.squareup.picasso:picasso:$picassoVersion"){
exclude group: "com.android.support"
}
implementation 'com.facebook.shimmer:shimmer:0.4.0'
}
Build.gradle (Module app)
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.myapplication"
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
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'
implementation project(path: ':posterlistlib')
}
Build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.41'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Why is the list of images being displayed in API 24, but is not in API 28?
For simple fix please use below code in AndroidManifest.xml
<application
android:usesCleartextTraffic="true"
...>
From API 28, URL with HTTP won't work by default, for more details on this topic check below link
https://developer.android.com/about/versions/pie/android-9.0-changes-28
To fix the images not loading, replace http://image.tmdb.org with https://image.tmdb.org
I am using ArthurHub image crop library in my project. but this error occurs
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
i have tried many solutions that were provided in other questions, but none of them works for me.
my build.gradle(module) file is here
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.lenovo.chatapp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:12.0.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.firebase:firebase-database:12.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
implementation 'com.google.firebase:firebase-core:12.0.0'
}
repositories {
mavenCentral()
}
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
i am doing project on motion sensor camera using android things and firebase and notification through mobile
Error:Execution failed for task
':mobile:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
i add "multidexenabled true" but no solution
this is App level gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "za.co.riggaroo.motioncamera"
minSdkVersion 27
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true //Added this
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
ext {
archVersion = '1.1.0'
playServices = "11.8.0"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation "com.google.firebase:firebase-core:${playServices}"
implementation "com.google.firebase:firebase-database:${playServices}"
implementation "com.google.firebase:firebase-storage:${playServices}"
implementation "com.google.firebase:firebase-auth:${playServices}"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
implementation "com.android.support:animated-vector-drawable:27.1.0"
implementation "com.android.support:support-v4:27.1.0"
implementation "com.android.support:support-media-compat:27.1.0"
implementation "com.android.support:cardview-v7:27.1.0"
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
compileOnly 'com.google.android.things:androidthings:0.7-devpreview'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "android.arch.lifecycle:runtime:${archVersion}"
implementation "android.arch.lifecycle:extensions:${archVersion}"
annotationProcessor "android.arch.lifecycle:compiler:${archVersion}"
implementation "com.android.support:appcompat-v7:27.1.0"
compile 'com.android.support:support-vector-drawable:27.1.0'
}
apply plugin: 'com.google.gms.google-services'