The app works fine with minSdkVersion 24 but upon reducing it to minSdkVersion 19 I am getting few errors. On running it in my device but there is no error upon gradle sync.The error log is posted. The dependencies work well with minSdkVersion 24, but not in minSdkVersion 19 , getting me the below listed errors and I need it to work on the lower version like minSdkVersion 19. Any help would be appreciated.
ERROR LOG HERE:
4 errors ,1 warning
Calculate task graph 122ms
Run tasks 2m 7s 746ms null
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\hp\.gradle\caches\modules-2\files-2.1\android.arch.lifecycle\common-java8\1.1.1\795d68cd761d093ccb235d1d91b8fd17c2ae25ff\common-java8-1.1.1.jar
com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
com.android.tools.r8.CompilationFailedException: Compilation failed to complete
com.android.tools.r8.utils.AbortException
null
Default interface methods are only supported starting with Android N (--min-api 24): void android.arch.lifecycle.DefaultLifecycleObserver.onCreate(android.arch.lifecycle.LifecycleOwner)
My app level gradle file.(minSdkversion 24 here)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.hp.mkchat"
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
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:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-core:11.4.2'
implementation 'com.google.firebase:firebase-auth:11.4.2'
implementation 'com.android.support:support-v4:27.1.1-beta1'
implementation 'com.google.firebase:firebase-database:11.4.2'
implementation 'com.google.firebase:firebase-storage:11.4.2'
implementation 'com.google.firebase:firebase-messaging:11.4.2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'com.firebaseui:firebase-ui-database:3.1.0'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:1.1.1"
// alternatively - just ViewModel
implementation "android.arch.lifecycle:viewmodel:1.1.1" // use -ktx for Kotlin
// alternatively - just LiveData
implementation "android.arch.lifecycle:livedata:1.1.1"
// alternatively - Lifecycles only (no ViewModel or LiveData).
// Support library depends on this lightweight import
implementation "android.arch.lifecycle:runtime:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
// alternately - if using Java8, use the following instead of compiler
implementation "android.arch.lifecycle:common-java8:1.1.1"
// optional - ReactiveStreams support for LiveData
implementation "android.arch.lifecycle:reactivestreams:1.1.1"
// optional - Test helpers for LiveData
testImplementation "android.arch.core:core-testing:1.1.1"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}
apply plugin: 'com.google.gms.google-services'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Check if your source compatibility & target compatibility is not Java-8. Set that to Java-8.
Removing these lines from the gradle helped remove the errors and run successfully on my phone for making it run in below android version 7
// alternatively - just ViewModel
implementation "android.arch.lifecycle:viewmodel:1.1.1" // use -ktx for Kotlin
// alternatively - just LiveData
implementation "android.arch.lifecycle:livedata:1.1.1"
// alternatively - Lifecycles only (no ViewModel or LiveData).
// Support library depends on this lightweight import
implementation "android.arch.lifecycle:runtime:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
// alternately - if using Java8, use the following instead of compiler
implementation "android.arch.lifecycle:common-java8:1.1.1"
// optional - ReactiveStreams support for LiveData
implementation "android.arch.lifecycle:reactivestreams:1.1.1"
// optional - Test helpers for LiveData
testImplementation "android.arch.core:core-testing:1.1.1"
i can't fix it by all the answer above, but i figured out the solution. I remove library appcompat v4 from my libs project folder.
yourprojectfolder > app > libs > appcompat...rar
delete that and restart your android studio.
Related
So I am running the Android Application but it stops in middle of Gradle Build and Displays the Error as:-
Could not find com.androidx.support:support-v4:28.0.0. Required by:
project :app
Search in build.gradle files
My Gradle File is as Follows:-
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'com.google.gms.google-services'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.alliaiseV1"
minSdk 26
targetSdk 31
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'
}
buildFeatures{
viewBinding true
}
}
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'
implementation 'com.google.firebase:firebase-firestore:24.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.camera:camera-core:1.1.0-alpha03'
implementation 'com.androidx.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.13.2'
implementation 'com.google.firebase:firebase-storage-ktx:20.0.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.annotation:annotation:1.3.0'
implementation 'com.android.databinding:viewbinding:7.1.2'
//Firebase
implementation 'com.google.android.gms:play-services-auth:20.1.0'
implementation platform('com.google.firebase:firebase-bom:29.0.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'
implementation 'com.google.firebase:firebase-auth:21.0.2'
implementation 'com.google.firebase:firebase-firestore-ktx:24.0.2'
implementation 'com.firebaseui:firebase-ui-firestore:8.0.0'
//lifecycle
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
//coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.0")
//Fragment Navigation
implementation 'androidx.fragment:fragment-ktx:1.4.1'
implementation("androidx.navigation:navigation-fragment-ktx:2.5.0-alpha03")
implementation("androidx.navigation:navigation-ui-ktx:2.5.0-alpha03")
//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-android-compiler:2.37"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
//CardView
implementation("androidx.cardview:cardview:1.0.0")
//splashscreen API
implementation "androidx.core:core-splashscreen:1.0.0-beta02"
//blur
implementation 'io.alterac.blurkit:blurkit:1.1.0'
implementation 'com.github.MikeOrtiz:TouchImageView:1.4.1'
//paging
implementation("androidx.paging:paging-runtime-ktx:3.1.1")
//touch
implementation 'com.github.smarteist:autoimageslider:1.4.0'
}
After that error I tried to remove the Dependency :
implementation 'com.androidx.support:support-v4:28.0.0'
Than after that I tried Running that got the error:-
Execution failed for task ':App : merge Debug Resources'.
> A failure occurred while executing
Com. android. build. Gradle. internal. res. Resource Compiler Runnable
> Resource compilation failed. Check logs for details.
Please help me regarding how do I solve this issue in Gradle to make the application work.
So the issue got resolved, the problem was in one of the string.xml files where there was a ' used in between of string
However this error acctuly means is there is some error in your resource files you need to start from drawbles and read every line trying to find error in your resource file.
Working on an Android app. The app was working fine, but suddenly I am getting build fails, with multiple 'cannot find symbol class' errors. I am pretty sure I have pushed several build releases on the same code, which is giving cannot find class errors now.
Errors in classes for which I have already included the implementations in the gradle files. (Error:(3, 35) error: cannot find symbol class SupportSQLiteDatabase), (Error:(3, 35) error: cannot find symbol class SupportSQLiteQuery)
Have tried changing details.useVersion to 28.0.0 but same result.
configurations.all
{
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.0.0'
}
}
}
}
Gradle entries:
android
{
compileSdkVersion 28
//buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 21
minSdkVersion 21
targetSdkVersion 25
versionCode 3
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies
{
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.constraint:constraint-layout:1.0.2'
// compile 'com.google.android.gms:play-services:7.8+'
// Barcode reader requires Version 8.1+ of playservices.
implementation 'com.google.android.gms:play-services-vision:15.0.2'
// testCompile 'junit:junit:4.12'
//Adding dependencies for the ROOM library
//
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:1.1.0"
// alternatively, just ViewModel
implementation "android.arch.lifecycle:viewmodel:1.1.0"
// alternatively, just LiveData
implementation "android.arch.lifecycle:livedata:1.1.0"
annotationProcessor "android.arch.lifecycle:compiler:1.1.0"
// Room (use 1.1.0-alpha1 for latest alpha)
implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
// Paging
implementation "android.arch.paging:runtime:1.0.0-alpha5"
// Test helpers for LiveData
testImplementation "android.arch.core:core-testing:1.1.0"
// Test helpers for Room
testImplementation "android.arch.persistence.room:testing:1.0.0"
//
//End ROOM library dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
//JSON GSON Depedency
implementation 'com.google.code.gson:gson:2.8.2'
//Volley Dependency for HTTP(s) requests
implementation 'com.android.volley:volley:1.1.0'
//Recycler view and card view
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
//ui Template related dependencies
implementation 'com.ogaclejapan.smarttablayout:library:1.6.1#aar'
implementation 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1#aar'
implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.6#aar') {
transitive = true
}
implementation 'com.heinrichreimersoftware:material-intro:1.6.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
//Retrofit libraries
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
//Firebase & Google Services
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-messaging:17.3.2'
//RxJava libraries
implementation 'io.reactivex.rxjava2:rxjava:2.0.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
//view injection
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// for dimension manage
implementation 'com.intuit.sdp:sdp-android:1.0.5'
//datepicker
implementation 'com.github.drawers:SpinnerDatePicker:1.0.6'
//Dependency for SupportSQLiteDatabase
implementation 'android.arch.persistence:db:1.1.1'
}
I tried invalidating/restarting - Did not work.
Removed Library files and sync with Gradle - did not work.
Upgraded Android Studio to 3.3.2. Used Kotlin V 1.3. Upgraded Gradle.
That removed the 'cannot find symbol class' error. But gave me new errors.
For some reason AndroidManifest.xml was throwing errors for the following format :
<activity
android:name=".transactions.xxx.xxx"
android:screenOrientation="portrait">
</activity>
But when the same code was changed to
<activity
android:name=".transactions.xxx.xxx"
android:screenOrientation="portrait"/>
It worked fine.
Finally I got 'program type already present : ...ListAdapter' error which was resolved by
Android: Compilation error with v7 support lib 27.1.0 "Program type already present" android.support.v7.recyclerview.extensions.ListAdapter
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
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
I have some problem with my project. In Android Studio 3.0, it works fine, but when I updated to 3.0.1, I have problem to merge dex.
I clean and rebuild project.
I use multiDexEnabled true with dependency
What is wrong:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
app level gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.rotaractnepalapp.rotraconversation"
minSdkVersion 15
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:design:27.1.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'com.firebaseui:firebase-ui-database:2.3.0'
implementation 'id.zelory:compressor:2.1.0'
compile 'com.android.support:support-annotations:27.1.0'
}
apply plugin: 'com.google.gms.google-services'
Add below dependency in gradle file
com.google.android.gms:play-services:11.4.0
Clean and Rebuild the application it will work.
I'm running into the same issue. I tried enabling multidex through the instructions here, but the error persisted. I also disabled instant run, as was suggested in another post, but that made no impact. I ended up having to revert all support libraries from version 27.1.0 back to version 27.0.2. Once I did, the error was corrected with no need for any multidex configuration. There is maybe an issue with 27.1.0.
CORRECTION: I found an unused library ('android.arch.paging:runtime:1.0.0-alpha4-1') and removed it, then updated the versions back to 27.1.0 with no issue. Since your minSdkVersion is 15, be sure to follow the step 2 under the Configure your app for multidex section to ensure your application is extending the multidexapplication class.