I am encounter a problem when I try to build the Android app and it appear error. The error appear after I add the last line in Gradle Build file (the natural language library).
Below is my gradle build file code
plugins {
id 'com.android.application'
id 'com.google.secrets_gradle_plugin' version '0.5'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.myvolunteer"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-firestore:23.0.3'
implementation 'com.firebaseui:firebase-ui-firestore:8.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation 'com.google.firebase:firebase-storage:20.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Import the BoM for the Firebase platform
// Declare the dependencies for the Firebase Cloud Messaging and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation 'com.google.firebase:firebase-analytics:19.0.1'
//Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
//Circle Image View
implementation 'de.hdodenhof:circleimageview:3.1.0'
//Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'com.karumi:dexter:6.2.3'
implementation 'com.google.android.gms:play-services-location:18.0.0'
//Cloud-lang,but it causes duplicate classes occur.
implementation 'com.google.cloud:google-cloud-language:2.1.2'
}
Some of the error that I get when try to build the project in Android Studio (it's too much I can't put all of them here)
Duplicate class com.google.api.Advice found in modules proto-google-common-protos-2.5.0 (com.google.api.grpc:proto-google-common-protos:2.5.0) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)
Duplicate class com.google.api.AuthProvider$1 found in modules proto-google-common-protos-2.5.0 (com.google.api.grpc:proto-google-common-protos:2.5.0) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)
Duplicate class com.google.cloud.audit.AuthenticationInfo$Builder found in modules proto-google-common-protos-2.5.0 (com.google.api.grpc:proto-google-common-protos:2.5.0) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)
Duplicate class com.google.longrunning.Operation$1 found in modules proto-google-common-protos-2.5.0 (com.google.api.grpc:proto-google-common-protos:2.5.0) and protolite-well-known-types-18.0.0-runtime (com.google.firebase:protolite-well-known-types:18.0.0)
How can I resolve this problem? I really need to add the Google Natural Language library to my app.
Updated: The attempt that I have tried but failed:
Firebase Android: Duplicate Protobuf classes found in modules
Duplicate Class while using firebase and google-cloud-texttospeech
Duplicate classes exception means that one of your dependencies uses implicitly the older or newer (with +) version of some library you also use in your project,
To resolve this issue you may add such block of code (put your library version after 'force') to your build.gradle file (Module:app):
configurations {
all {
resolutionStrategy {
// do not upgrade above 3.12.0 to support API < 21 while server uses
// COMPATIBLE_TLS, or okhttp3 is used in project
force 'com.squareup.okhttp3:okhttp:3.12.0'
force 'com.squareup.okhttp3:logging-interceptor:3.12.0'
}
}
}
You may also exclude some group from your dependencies. For a single dependency you way write:
dependencies {
// example
implementation('log4j:log4j:1.2.15') {
exclude group: 'javax.jms', module: 'jms'
}
}
Related
I am getting the following duplicate class error when I run my Android application (I didn't include all the errors, but the duplicate errors are all coming from org.apache.commons.lang3.* and org.apache.commons.logging.*):
Duplicate class org.apache.commons.lang3.AnnotationUtils found in modules commons-lang3-3.4.jar (org.apache.commons:commons-lang3:3.4) and commons-lang3-3.7.jar (commons-lang3-3.7.jar)
Duplicate class org.apache.commons.lang3.AnnotationUtils$1 found in modules commons-lang3-3.4.jar (org.apache.commons:commons-lang3:3.4) and commons-lang3-3.7.jar (commons-lang3-3.7.jar)
...........
Duplicate class org.apache.commons.logging.impl.WeakHashtable found in modules commons-logging-1.2.jar (commons-logging-1.2.jar) and commons-logging-1.2.jar (commons-logging:commons-logging:1.2)
Duplicate class org.apache.commons.logging.impl.WeakHashtable$1 found in modules commons-logging-1.2.jar (commons-logging-1.2.jar) and commons-logging-1.2.jar (commons-logging:commons-logging:1.2)
Duplicate class org.apache.commons.logging.impl.WeakHashtable$Entry found in modules commons-logging-1.2.jar (commons-logging-1.2.jar) and commons-logging-1.2.jar (commons-logging:commons-logging:1.2)
Duplicate class org.apache.commons.logging.impl.WeakHashtable$Referenced found in modules commons-logging-1.2.jar (commons-logging-1.2.jar) and commons-logging-1.2.jar (commons-logging:commons-logging:1.2)
Duplicate class org.apache.commons.logging.impl.WeakHashtable$WeakKey found in modules commons-logging-1.2.jar (commons-logging-1.2.jar) and commons-logging-1.2.jar (commons-logging:commons-logging:1.2)
The error stems from this line of code in the gradle (I need to use the docx4j library because my app has to read in the contents of MS Word files selected by the user):
implementation "org.docx4j:docx4j:3.3.0"
Below is the complete code of my gradle file:
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.diffchecker"
minSdkVersion 21
targetSdkVersion 29
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
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.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'io.github.java-diff-utils:java-diff-utils:4.5'
// For developers using AndroidX in their applications
implementation 'pub.devrel:easypermissions:3.0.0'
// For developers using the Android Support Library
implementation 'pub.devrel:easypermissions:2.0.1'
implementation 'com.google.android.gms:play-services-ads:18.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation files('libs/commons-text-1.2.jar')
//Thanks for using https://jar-download.com
implementation 'org.webjars.bowergithub.telecomsante:pdf-viewer:2.2.0'
implementation 'com.tom_roush:pdfbox-android:1.8.10.1'
implementation 'com.bskim:maxheightscrollview:1.0.0#aar'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation files('libs/commons-logging-1.2.jar')
implementation files('libs/commons-lang3-3.7.jar')
// Docx4j is the library used to read Word documents
// https://mvnrepository.com/artifact/org.docx4j/docx4j
implementation "org.docx4j:docx4j:3.3.0"
}
How do I use the docx4j library in my gradle without running into duplicate conflicts with the commons-lang3 and commons-logging libraries?
I think I found a similar way of what we did at the beginning but this time with both exclusions.
Try this:
implementation ('org.docx4j:docx4j:3.3.0') {
['org.apache.commons','commons-logging'].each {
exclude group: "$it"
}
}
Erase local lib and put this on the gradle
https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'
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 migrating my Android app project from GCM to FCM. For this I use Firebase assistant tool in Android Studio and followed instructions from Google developer guide. Everything went fine and changed my app code for FCM according to Assistant tool. Now, its time to run and test app. And I got following strange error :
cannot access zzbfm class file for com.google.android.gms.internal.zzbfm not found
I am getting this error where I am using google maps and trying to set marker position.
Here's my app level gradle :
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
maven { url 'https://dl.bintray.com/kennyc1012/maven' }
}
android {
signingConfigs {
msapp {
}
}
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.package"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
useLibrary 'org.apache.http.legacy'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//Default
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-messaging:11.8.0'
testImplementation 'junit:junit:4.12'
//modules
implementation 'com.facebook.android:facebook-android-sdk:4.+'
//jar files
implementation files('libs/classes.jar')
implementation files('libs/YouTubeAndroidPlayerApi.jar')
//google repos
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:support-v4:26.0.0'
implementation 'com.android.support:recyclerview-v7:26.0.0'
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.android.support:design:26.0.0'
//square lib
implementation 'com.squareup.retrofit2:converter-gson:2.0.0'
//compile 'com.squareup.leakcanary:leakcanary-android:1.5'
//text manupulation
implementation 'commons-lang:commons-lang:2.6'
//permission library.
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.google.firebase:firebase-core:16.0.3'
}
apply plugin: 'com.google.gms.google-services'
To resolve your problem, first i will ask you to always use specified and updated version.
1. Replace + with specific version here : classpath 'io.fabric.tools:gradle:1.25.4'
2. Try to use same version for now to run the apk,
compileSdkVersion 27
buildToolsVersion '27.0.3'
targetSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
3. Use an updated version of google play service
implementation 'com.google.android.gms:play-services:16.0.3'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
This will fix your problem.
Please Change your Firebase and Google Library to same version .
For an Example like this
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-analytics:12.0.1'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
//your firebase lib version to the same version
implementation 'com.google.firebase:firebase-core:12.0.1'
In most cases is required to upgrade play-services and firebase version dependencies, maybe the last one available if you are using androidx but if not:
Try to check it out the maven_repository and choose some version that helps you fix it. For example:
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
the chosen version is the last one before version 17 due to the v17.0.0 require androidx (in play-service)
Don't forget to update your google-service in your build.gradle(project)
classpath 'com.google.gms:google-services:4.3.0'
I encountered same issue after migrating AndroidX and
Solved by changing version of gms library for maps and location as below
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
According to the official documentation regarding Latest SDK versions, please change the following line of code:
implementation 'com.google.firebase:firebase-messaging:11.8.0'
to
implementation 'com.google.firebase:firebase-messaging:17.3.1'
And according to official documentation regarding on to set up Google Play Services, please change the follwing lines of code:
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
to
//implementation 'com.google.android.gms:play-services:11.8.0' //Commented line
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-maps:15.0.1
Please also be sure to have:
classpath 'com.google.gms:google-services:4.1.0'
In your top level build.gradle file.
Just update versions of libraries "......gms:play-services....." to the latest
To check the latest versions, refer this link
I receive this warning:
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 27.1.1, 27.1.0. Examples include
com.android.support:animated-vector-drawable:27.1.1 and
com.android.support:exifinterface:27.1.
I understand this, but why is this warning shown to me even though all the com.android.support versions are the same? (27.1.1)
this is the content of my file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.app.sin.retrolist"
minSdkVersion 18
targetSdkVersion 27
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:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.squareup.picasso:picasso:2.71828' }
To see why a specific dependency is included in your dependency tree, you can (assuming that your main module is named app and you are on macOS) run a simple:
./gradlew app:dependencies
In the console output, you will see the full dependency tree and how library versions are resolved.
The proper way to deal with dependencies conflicts like this is to explicity define a resolution strategy:
configurations.all {
resolutionStrategy {
force 'com.android.support:exifinterface:27.1.1'
}
}
This must be placed in the root of your build.gradle file in the app module.
Overriding the conflicting dependency with:
dependencies {
...
implementation 'com.android.support:exifinterface:27.1.1'
}
is less correct, as your module doesn't directly depends on this library so, if for example future versions of your dependencies won't depend on it anymore, it will still be included in the list of resolved dependencies even if you don't need it.
Even better, you could define:
ext {
supportLibVersion = "27.1.1"
}
in your main build.gradle file, and then use it wherever you need it:
configurations.all {
resolutionStrategy {
force "com.android.support:exifinterface:$rootProject.supportLibVersion"
}
}
dependencies {
...
implementation "com.android.support:appcompat-v7:$rootProject.supportLibVersion"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibVersion"
...
}
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.