Can't compile new Material library in Gradle - android

I can't add the new Material Design library.
When I add compile 'com.google.android.material:material:1.0.0-alpha1' and I sync the project, I get this two errors:
error: resource android:attr/fontVariationSettings not found.
error: resource android:attr/ttcindex not found.
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "rockthesport.com.pruebasmaterial"
minSdkVersion 19
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.constraint:constraint-layout:1.1.0'
compile 'com.google.android.material:material:1.0.0-alpha1'
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'
}
Any suggestions?
Thanks!

To use the new Material Components library 'com.google.android.material:material:1.0.0-alpha1' you have to use
android {
compileSdkVersion 'android-P'
defaultConfig {
targetSdkVersion 'P'
}
...
}

Related

Android Studio : Failed to resolve: fragment-1.1.0

I want to add a library called material to my projects but it gives me the mentioned error in the title when I try to sync it. Android Studio 4.0.1.
build.gradle(app module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.1"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 14
targetSdkVersion 30
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'
/*implemention for material shown below*/
implementation 'com.google.android.material:material:1.3.0-alpha02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Gradle dependencies in Android Studio

Error in gradle file in android studio.
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.mih.demo2"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.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:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.4'
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'
}
Error in implementation 'com.android.support:appcompat-v7:28.0.0'
Guide me to solve this Error In the android studio. I search a lot but cannot find the solution.
Put these flags in your gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
then use SDK version 28 for both compileSdkVersion and targetSdkVersion:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.mih.demo2"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.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:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:17.2.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'
}
It works fine!

Is it possible to target Android 28 (eg`targetSdkVersion 28`) and use both appcompat-v7 and Firebase?

Has anyone managed to target Android 28 (eg set targetSdkVersion 28) and use Firebase? My build.gradle is as below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.google.firebase.example.fireeats"
minSdkVersion 28
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-rc02'
implementation 'com.google.firebase:firebase-core:16.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'
}
apply plugin: 'com.google.gms.google-services'
Android Studio warns of mixed versions: Found versions 28.0.0-rc02, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-rc02 and com.android.support:support-media-compat:26.1.0
Is Firebase 16.0.3 incompatible with the Android 28 support lib?
At time of writing, Firebase depends on the support library versions 27 so you do need to provide explicit overrides. See the working build file below.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.google.firebase.example.fireeats"
minSdkVersion 28
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'
implementation 'com.android.support:support-media-compat:28.0.0' // NEED TO ADD
implementation 'com.android.support:support-v4:28.0.0' //NEED TO ADD
implementation 'com.google.firebase:firebase-core:16.0.4'
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'
}
apply plugin: 'com.google.gms.google-services'

Failed to resolve: com.google in Android Studio 3.1.3

Adding Firebase dependencies is giving below error:
Failed to resolve: com.google
This is my app/build.gradle
`
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xxxxxxx.xxxxx"
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-alpha3'
implementation 'com.google.firebase: firebase-core: 16.0.0'
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'
}
apply plugin: 'com.google.gms.google-services'
`
I referred to "Failed to resolve: com.google.firebase:firebase-core:9.0.0" but, didn't worked.
Thank you in advance.
Check this line implementation 'com.google.firebase: firebase-core: 16.0.0'
You have a space between com.google.firebase: and firebase-core:16.0.0. Remove those spaces

Error implementing Material Design in Android

I've been reading over the new material design website but I'm having an issue implementing it.
The application I'm currently working in is a simple test applications with nothing more than a button and some textviews.
The problem comes after placing implementation 'com.google.android.material:material:1.0.0-alpha1' in the gradle file.
heres my build.gradle(app) file
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.user.firebasemessagingtest"
minSdkVersion 19
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'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.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.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.2'
implementation 'com.google.firebase:firebase-ml-vision:15.0.0'
implementation 'com.google.android.material:material:1.0.0-alpha1'
}
apply plugin: 'com.google.gms.google-services'
I've got 4 errors,
error: resource android:attr/dialogCornerRadius not found.
error: resource android:attr/fontVariationSettings not found.
error: resource android:attr/ttcIndex not found.
error: failed linking references.
I have included the maven in the project gradle file like stated in the documentation.
Try this
change compileSdkVersion and Support Libraries version
compileSdkVersion 'android-P'
Support Libraries to '28.0.0-alpha1'
and use
api 'com.android.support:design:28.0.0-alpha1'
EDIT
Update your SDK Platform update - Android P Preview (latest)
and also make targetSdkVersion 'P'
Than Clean-Re_Build-Run your project
EDIT 2
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "com.example.nilesh.testapp"
minSdkVersion 19
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'
}
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
compile 'com.android.support:design:28.0.0-alpha1'
compile 'com.android.support:cardview-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.2'
implementation 'com.google.firebase:firebase-ml-vision:15.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
repositories {
mavenCentral()
}
Hope this helps
Set compileSdkVersion as 'android-P'.Match the support library with the compileSdkVersion. For instance, implementation 'com.android.support:support-v4:28.0.0-alpha1' instead of implementation 'com.android.support:appcompat-v7:27.1.1'.
Replace implementation 'com.google.android.material:material:1.0.0-alpha1' with api 'com.android.support:design:28.0.0-alpha1'.
The app build.gradle should look something like this.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "com.wolfrevokcats.myapp"
minSdkVersion 15
targetSdkVersion 27
versionCode 16
versionName "2.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable false
minifyEnabled false
shrinkResources 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"
api 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
implementation ('com.someone.addons:library:1.6.1#aar'){
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
exclude module: 'support-v4'
}
implementation 'com.google.android.gms:play-services-location:15.0.1'
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'
}
As 'com.android.support:design:28.0.0-alpha1' is being used, our code will have to change to android.support.design instead of com.google.android.material libraries. Here's an example using the new Bottom App Bar widget.
<android.support.design.bottomappbar.BottomAppBar
android:id="#+id/toolbar"
style="#style/Widget.MaterialComponents.BottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:fabAttached="true"
app:fabAlignmentMode="center"/>

Categories

Resources