Hello kind people of the internet.
My name is Paul.
I've started to learn Android development using Kotlin, lately I've been following a couple of tutorials regarding RecyclerView, LiveData and Lifecycle.
At first I honestly forgot to declare the dependencies inside my gradle script.
But I have discovered that the functionality actually works as expected.
Can somebody please explain to me this phenomenon:
is it because Android Studio "saw" my imports and automatically "defined" and downloaded the dependencies ?
is it because of the compileSdk version?
Here is a sample of my dependencies block from one of my projects
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Also here is my config
defaultConfig {
applicationId "com.example.myrecycler"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Thank you!
Related
I want to publish my Android mobile application which uses an encrypted SQLCipher database.
During deployment my release does not meet the obligation to provide a 64-bit version on Google Play.
I followed the prescriptions for Support 64-bit architectures but no results.
I need help please!
defaultConfig {
applicationId "com.mdc.droit"
minSdkVersion 14
targetSdkVersion 29
versionCode 3
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.sqlite:sqlite:2.1.0'
implementation 'com.google.android.gms:play-services-ads:17.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'nl.littlerobots.cupboard-tools:sqlcipher:0.3.1' //SQlCipher implementation HERE
}
Android Studio Analyze APK
Google Play Error
We added 64-bit support to SQLCipher for Android in February of 2017. You may need to update your dependencies, the latest version of SQLCipher for Android is 4.4.0.
my app was working fine while i was using firestore version 11.8.0 but there was always a warning regarding the firestore version it asks me to upgrade the latest version 17.1.0
after upgrading the version,the application show errors, and the android studio keeps telling me
//Cannot fit requested classes in a single dex file. Try supplying a main-dexlist.
I don't know why is the version of firebase storage has to do with the Multidex?
here is my build gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.moham.trial"
minSdkVersion 19
targetSdkVersion 28
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(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-firestore:17.1.0'
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'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.android.support:cardview-v7:28.0.0-rc02'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
}
apply plugin: 'com.google.gms.google-services'
Building an android app compiles the app into bytecode (executable code) in the form of a DEX file. The compiled bytecode files (DEX files) only support 64K (65,536) methods before having to split into DEX files.
Adding the firestore library adds a lot of methods and causes this limit to be exceeded and so multiDexEnabled true is required to allow it to split into multiple files.
You can find more information at: https://developer.android.com/studio/build/multidex
Error : Sync failed. Unresolved Android dependencies. Failed to resolve: com.android.support:appcompat-v7:28.1.1
Config:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.ercess.ercess_app1"
minSdkVersion 15
targetSdkVersion 28
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.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:appcompat-v7:28.1.1'
implementation 'com.squareup.picasso:picasso:2.71828'
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'
}
How to resolve this?
Replace
implementation 'com.android.support:appcompat-v7:28.1.1
with
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
Currently, the most recent available release for appCompat is 28.0.0-rc01, you are trying to pull an unavailable version of appcompat library.
Root cause: The version 28.1.1 is not exist.
Solution: Use the latest stable version
implementation 'com.android.support:appcompat-v7:27.1.1'
or use latest unstable version
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
Many answers already on this one but I feel like noone explaines how to keep it up to date, just how to fix this specific version. So here it is
The com.android.support:appcompat version must match the compileSdkVersion
It is preferable to use stable versions if you release to production
Look on the android website to find the lastest stable version that correspond to your compile version (even is this link gets broken, the info will be available somewhere on the official website)
Example, as of today (end of january 2019), the lastest stable support library version is 28.0.0 (according to android website), so the correct implementation is
implementation 'com.android.support:appcompat-v7:28.0.0'
you'd have to use api "com.android.support:appcompat-v7:27.1.1" -
or the later (future) api "androidx.appcompat:appcompat:1.0.2"
from androidx.
using "release candidates" and "alpha versions" is discouraged, because these are not well tested.
just see the official documentation ...it recommends 27.1.1.
I solved this by trial and error and using some of the answers above.
I changed the appcompat to a lower version "com.android.support:appcompat-v7:27.1.0"
along with changing
compileSdkVersion 27
and
targetSdkVersion 27
I'm still getting warnings but Picasso should now run.
You need also add: implementation 'com.android.support:support-v4:28.0.0' in your gradle file like this:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
and this is a full implementation:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
Please add these below dependencies to solve the issue, try it:
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-v13:27.1.1'
implementation 'com.android.support:design:27.1.1'
also change the version of AppCompat as:
implementation 'com.android.support:appcompat-v7:27.1.1'
AppCompat Sometimes doesn't work alone. Adding these might solve your issue.
replace
implementation 'com.android.support:appcompat-v7:28.1.1'
with
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
I have been working on a project where I am trying to build a messaging application in Android Studio using Google Firebase. I previously had to restart the project due to an error after reaching this stage of the tutorial I have been following which requires you to add an implementation of the 'com.firebaseui:firebase-ui-database:4.1.0' (Or whatever the most recent version is) in my project gradle file and update the existing dependencies I am using accordingly.
I am still relatively new to app dev and as such don't want to mess up this project and start from scratch again by screwing up my gradle file. So could somebody show me what my build.gradle file should look like with the new dependency added and the existing dependencies correctly updated before syncing?
Info on adding the dependency can be found under this link, mainly under the 'Installation' and 'Dependencies' headings. https://github.com/firebase/FirebaseUI-Android
My current gradle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.conormcadorey.chatbox"
minSdkVersion 21
targetSdkVersion 28
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:28.0.0-beta01'
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.android.support:support-v4:28.0.0-beta01'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
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'
//creates a rounded user profile image
implementation 'de.hdodenhof:circleimageview:2.2.0'
//ArthurHub - allows user to crop their profile image
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
//Picasso - image uploader
implementation 'com.squareup.picasso:picasso:2.71828'
}
apply plugin: 'com.google.gms.google-services'
ps - I appreciate that this may be a simple or obvious question, however when I attempted this myself I ended up having to rebuild the project from scratch so any help would be greatly appreciated.
Using Android Studio v3.1.3
According to the docs:
As of version 4.1.0, FirebaseUI has the following dependency versions:
Library Version
firebase-auth 16.0.1
play-services-auth 15.0.1
firebase-database 16.0.1
firebase-firestore 17.0.1
firebase-storage 16.0.1
Therfore change the following libraries:
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
into this:
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
Also add the firebase-core:
implementation 'com.google.firebase:firebase-core:16.0.1'
Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.
I am trying to understand ViewModel and LiveData concepts in android. I am making a practice project but when i added implementation 'androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1' line in my app level gradle file it shows me
Failed to resolve:
androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1.
I have searched on google for solution and i found this answer, it works when i compile only viewmodel library but if i compile extensions library using same method as implementation group: 'androidx.lifecycle', name:'lifecycle-extensions-ktx', version: '2.0.0-alpha1', it shows the same error as above.
I have also tried to find it on Maven repositories site here but i didn't have any information for how to compile it.
UPDATE
App Level Build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "***************"
minSdkVersion 19
targetSdkVersion 28
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 "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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'
implementation group: 'androidx.lifecycle', name:'lifecycle-extensions-ktx', version: '2.0.0-alpha1'
implementation group: 'androidx.lifecycle', name:'lifecycle-viewmodel-ktx', version: '2.0.0-alpha1'
}
UPDATE
As per #Dr.jacky's comment and Android Developers Documentation,
The APIs in lifecycle-extensions have been deprecated. Instead, add dependencies for the specific Lifecycle artifacts you need.
More Info at https://developer.android.com/jetpack/androidx/releases/lifecycle
I have found the answer. As Thunder Knight said here it seems to be that the repository was emptied somehow. Hence, you can not download it from the repository.. I agree with this and so i was looking for answer on mvnrepository.com and i found it here. I have to add
implementation group: 'androidx.lifecycle', name: 'lifecycle-extensions', version: '2.0.0-alpha1'
line for adding lifecycle-extensions and also i was adding -ktx in name of library but it was the mistake. In documentation they have not commented to add -ktx in line of lifecycle-extensions.
Credits:- #Thunder Knight
The current version is 2.2.0
use -ktx for kotlin implementation
and kapt for annotationProcesssor
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.2.0'
Check the developer site for more information
https://developer.android.com/topic/libraries/architecture/adding-components
Just dont use -ktx in lifecycle-extensions. There is no separate '-ktx' version of the dependency unlike in viewmodel
Add these line
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
and comment these lines
// testImplementation 'junit:junit:4.13.2'
//androidTestImplementation 'androidx.test.ext:junit:1.1.2'
//androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
in my case i was trying to using room with LiveData. and all i did was remove the suspend key word from the query method.
Reference: post in forums.bignerdranch.com
Error:
Failed to resolve: androidx.lifecycle:lifecycle-extensions:2.3.1
Solution:
The APIs in lifecycle-extensions have been deprecated. Instead, add dependencies for the specific Lifecycle artifacts you need.
More details: developer.android.com