I'm having issues with the build.gradle file, specially the module 'android.x.lifecycle'.
I have the following error
ERROR: Failed to resolve: androidx.lifecycle:lifecycle:2.2.0-beta01
This is the last version of androidx.lifecycle
I don't know if it a syntax error
This is the build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.flixarts.ar.englishnow"
minSdkVersion 14
targetSdkVersion 29
buildToolsVersion '25.0.2'
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'
}
}
buildToolsVersion = '28.0.3'
}
dependencies {
implementation 'androidx.lifecycle:lifecycle:2.2.0-beta01'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.1.0-beta01'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
implementation 'com.android.support:multidex:1.0.3'
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 'androidx.cardview:cardview:1.0.0'
}
Change this line:
androidx.lifecycle:lifecycle:2.2.0-beta01
with one of these:
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0-beta01"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.2.0-beta01"
implementation "androidx.lifecycle:lifecycle-livedata:2.2.0-beta01"
implementation "androidx.lifecycle:lifecycle-livedata-core:2.2.0-beta01"
implementation "androidx.lifecycle:lifecycle-runtime:2.2.0-beta01"
More info about Lifecycle here.
Also:
change com.android.support:multidex:1.0.3 to androidx.multidex:multidex:2.0.1 since you are using androidx library
you are adding implementation 'androidx.appcompat:appcompat:1.1.0' thrice
remove the support library: implementation 'com.android.support.constraint:constraint-layout:1.1.3'
remove the buildToolsVersion '25.0.2' and buildToolsVersion = '28.0.3'(don't use = in any case). You can specify buildToolsVersion "29.0.2" in the android block or just omit it and gradle will automatically use the latest version according to the targetSdkVersion specified
Related
When I try to build my project I get this error:
The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten
I Found many similar questions but they were not helpful to me I work with this Library:
And this is my code from Build:gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.majaxtn.codingup"
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 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.yarolegovich:discrete-scrollview:1.4.9'
implementation 'com.google.firebase:firebase-core:17.4.3'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03'
implementation 'androidx.appcompat:appcompat:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
And below is the screen with my problem
Screenshot with error
I suggest you upgrade to AndroidX:
dependencies {
implementation
'com.google.android.material:material:1.1.0'
implementation 'androidx.appcompat.appcompat:1.1.0'
implementation
'androidx.constraintlayout.constraintlayout:1.1.3'
implementation 'androidx.browser.browser:1.0.0
}
PS: the versions are not the latest though, just pointing you in the right direction.
Remove these:
implementation
'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-v4:28.0.0
implementation
'com.android.support.constraint:constraint-layout:1.1.3'
Edit:
Add this in your gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
Then do a clean build after you sync.
Cheers!
I am new to Android Studio and I'm trying to learn how to use navigation drawer. However, I can't make it appear in preview. I have tried doing it automatically when creating a new activity but the result is the same here is what it looks like
These are the dependencies:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example."
minSdkVersion 21
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 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.google.firebase:firebase-storage:16.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
If you want show in editor preview - tools:openDrawer="start"
I found similar question:
What's the purpose of tools:openDrawer="start" when creating a DrawerLayout (with NavigationView) from the wizard?
I want to add the app:layout_behavior attribute in xml file but it not supported. Which library should I add in gradle file?
compile 'com.android.support:design:22.2.0
when I add this compile library android Studio gives error I have to androidx library to support that app:layout_behavior.
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.expensemanager"
minSdkVersion 16
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 'androidx.appcompat:appcompat: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-analytics:17.2.0'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-database:19.1.0'
implementation 'com.google.firebase:firebase-functions:19.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
please help me what should i implement to support app:layout_behavior
Use the Material Components Library which is a drop-in replacement for Android's Design Support Library.
implementation 'com.google.android.material:material:1.1.0-beta02'
or the latest stable version:
implementation 'com.google.android.material:material:1.0.0'
The build.gradle file at app level is given below
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.example.sscmessenger"
minSdkVersion 19
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'])
//noinspection GradleCompatible
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.android.support:support-v4:28.0.0-rc01'
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-database:19.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.3'
}
Blockquote
The class android.support.v7.widget.Toolbar can be found in the appcompat library.
Pay attention because
implementation 'com.android.support:appcompat-v7:28.0.3'
doesn't exist.
The 28.0.0 is the last version of support libraries.
Change your dependencies:
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
//...
Better migrate your project to androidx.
I'm trying to set up my SettingsFragment but
import PreferenceFragmentCompat hasn't been working.
Is there a way of doing this with AndroidX?
Dependency
implementation 'androidx.preference:preference:1.0.0-rc02'
Gradle flie
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.idealorb.payrollapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
android.defaultConfig.vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0-rc02'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc02'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-rc01'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha05'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha05'
implementation 'androidx.preference:preference:1.0.0-rc02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
compileSdkVersion 28
You have to set compileSdkVersion to 29 in order to use androidx-namespaced libraries