I'm using Android Studio 3.1.4. In order to use the latest material design library, I updated the compile and target SDK versions to 28. Right now, I'm using some TextInputLayouts and TextInputEditTexts in a basic linear layout, and the design preview doesn't render them properly. It also doesn't render any elements that follow it properly. I'm getting the following errors in the Design Preview:
java.lang.IllegalArgumentException: Underflow in restoreToCount - more restores than saves
at android.graphics.Canvas.restoreToCount(Canvas.java:604)
at android.support.design.widget.CutoutDrawable.postDraw(CutoutDrawable.java:113)
at android.support.design.widget.CutoutDrawable.draw(CutoutDrawable.java:87)
at android.support.design.widget.TextInputLayout.draw(TextInputLayout.java:1575)
Here's what the preview actually looks like - Not particularly helpful to design in:
I've hunted around for a fix for this and can't seem to find anything that's useful for this current version of Android Studio or SDK 28. Here's the app build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.the.appname.here"
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support:exifinterface:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:28.0.0-rc01'
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:recyclerview-v7:28.0.0-rc01'
implementation 'com.android.support:cardview-v7:28.0.0-rc01'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation ('com.twitter.sdk.android:twitter:3.3.0#aar') {
transitive = true
}
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
apply plugin: 'com.google.gms.google-services'`
Is it possible there's an issue with one of the release candidate libraries?
In order to make this work I changed:
implementation 'com.android.support:appcompat-v7:28.0.0-rc01' (rc01)
to
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1' (alpha1)
I saw this online and it is working according to my tests, the only downside is that you would have to make this change on every project.
Related
I want to use RecycleView in my android project. For that I tried to add 'com.firebaseui:firebase-ui-database:8.0.0' to my module gradle. After that I am getting an error as "Corrupt serialized resolution result. Cannot find selected module (287) for constraint platform-runtime -> com.google.firebase:firebase-iid:21.1.0"
I am new to android developments and I could not resolve this problem.
Here is my module gradle
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
//id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.bookmark"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true //multidex Error fix
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.google.firebase:firebase-firestore:23.0.3'
implementation 'androidx.multidex:multidex:2.0.1' //Multidex error fix
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation 'com.firebaseui:firebase-ui-database:8.0.0'
//implementation 'com.firebaseui:firebase-ui-database:7.2.0'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.cardview:cardview:1.0.0"
//implementation 'com.google.firebase:firebase-firestore:21.4.0'
//implementation 'com.firebaseui:firebase-ui-auth:7.2.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Error disappear when I comment implementation 'com.firebaseui:firebase-ui-database:8.0.0'
Can you give me a solution?
Based on my findings stuff like these are usually caused by corner cases in the dependency graph computation, so changing declaration order or adding / removing dependencies can make the problem go away.
And you should also try Clean project then Rebuild, and/or Invalidate cache and restart.
I had a similar problem and it resolved it.
I've been getting familiar with Android Studio for the last couple of days and it has been stable for the most part , until I added the Material Design dependency and I got a whole bunch of errors when building the project.
I've been tinkering around with buildtools/sdk versions but nothing seems to work.
Here's my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "app.anuythe.com.apend"
minSdkVersion 24
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.google.android.material:material:1.1.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
}
Errors:
https://i.stack.imgur.com/OYWDg.png
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'
}
PS: the versions are not the latest though, just pointing u in the right direction.
Cheers!
I'm trying to use older dependencies for my app and in the XML file it doesn't recognize the layout and it gives me an error. Moreover the build.gradle files compiles perfectly yet shows a red underline below the implementations of cardview and recyclerview.
Xml File:
Attached picture of what I need but yet isn't recognized.
https://i.stack.imgur.com/bZIbm.jpg
build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.example.testsuccess"
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.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-database:16.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:21.+'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.firebaseui:firebase-ui-database:4.2.0'
}
I've even tried implementing
implementation 'com.android.support:cardview-v7'
implementation 'com.android.support:recyclerview-v7'
But it forces me to Migrate to Androidx libraries and doesn't allow me to use the old ones.
Note: the layout is an additional file in the project.
Add:
implementation 'androidx.cardview:cardview:1.0.0'
This will bring in androidx.cardview.widget.CardView, which is what your layout is looking to use.
If you want to use the old class names, you need to disable the androidx from gradle.properties file using
android.useAndroidX=false
android.enableJetifier=false
Which forces the androidx to be disabled.
OR
Dont want to disable androidx.
Then replace this line
from
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
to
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
This will work fine in AndroidX.
I'm getting an error regarding mixing of dependency versions . Few days back it was working absolutely fine but from nowhere the issue popped up .
It's showing : All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-alpha1, 28.0.0. Examples include com.android.support:customtabs:28.0.0-alpha1 and com.android.support:animated-vector-drawable:28.0.0
I'm using Firebase dependencies also , is it causing any trouble ?
I tried to add some extra dependencies (as popped up) , but nothing is working .
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "namantiwari.epplieschool"
minSdkVersion 21
targetSdkVersion 28
versionCode 7
versionName "1.4"
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-alpha1'
implementation 'com.android.support:customtabs:28.0.0-alpha1'
implementation 'com.android.support:support-vector-drawable:28.0.0-alpha1'
implementation 'com.android.support:support-media-compat:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-messaging:17.3.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 'com.google.firebase:firebase-core:16.0.1'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
Android X is supposed to solve these issues.
How to migrate to Android X
I am using mancj/MaterialSearchBar to set up a search bar which looks like the Playstore's one. However, I'm having some trouble with my Gradle build.
The error
build.gradle (Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.."
minSdkVersion 27
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 27
renderscriptSupportModeEnabled true
}
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.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.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'
implementation 'com.github.mancj:MaterialSearchBar:0.7.6'
}
Solution tried
I already tried to replace the implementation of this API with the following line: implementation 'com.github.mancj:MaterialSearchBar:0.7.6:27.1.1' but it didn't find it (meaning it doesn't exist).
The library (version 0.7.6) is using 3 dependencies (AppCompat-v7, RecyclerView-v7 and CardView-v7) related to the version 25.4.0.
Because you are already using AppCompat-v7 and RecyclerView (RecyclerView is included into Design), the library is going to use the version 27 instead of 25.
You only have one more library to convert from 25 to 27, CardView-v7.
If to add implementation 'com.android.support:cardview-v7:27.1.1',
this will force the library to use the version 27 instead of 25, and therefor allow you to compile.
You still need to take care by testing your app to see if its behavior is correct, as the library was not tested to use 27 yet.
use latest version
implementation 'com.github.mancj:MaterialSearchBar:0.8.2'
add this code to the the project level build.gradle file
maven { url "https://jitpack.io" }
one can substitute the conflicting version alike this (and hope it will still work with 27.1.1):
implementation "com.android.support:cardview-v7:27.1.1"
implementation ("com.github.mancj:MaterialSearchBar:0.7.6") {
exclude group: "com.android.support", module: "cardview-v7"
}