Grey screen showing up on layout xml after switching to Androidx - android

After switching to Androidx, when I go back to my activity xml, it shows nothing but a grey screen with "androidx.constraintlayout....ConstraintLayout"
I tried messing around with the gradle and switching the constrained layout version but no luck.
Someone please help me with this because I dont know what to do.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.hammad.firstapplication"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
}

In Android Studio Press Build>>Rebuild Project

Try degrading your constraint layout verison
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
Use 1.1.2 or 1.1.1 instead of 2.0.0-alpha4

Try click on the "Sync project with Gradle files” button shown by the arrow in the Android Studio:

Related

Errors installing Material Design for android studio

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!

Unable to add layouts to an activity using Android Studio

Using Android Studio, in my activity's .xml I can't edit the layout in regards to which layout type the overall one is. The only way for me to change layouts is to copy-paste the layout code from somewhere on the internet and I've been doing it like that for the past month.
This is ridiculous. Why am I having this issue?
Drag and dropping a layout on to the activity inside of the designer does nothing.
Upon creating an empty activity of which the default layout is "ConstraintLayout", I can't do anything with that layout inside of the designer. I can only remove it by deleting the code from within the .xml view.
My build.gradle (Module: app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "hr.package.name.testsigninna"
minSdkVersion 23
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 'com.google.android.gms:play-services-auth:17.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
The problem is present in all projects I make.
I'm not sure but please check the gradle or it's version may be too old whether all the dependencies are working or not. Sync them and rebuild the project.

how to solve the problem of "Inconsistencies in the existing project dependencies found"?

I am learning to write android apps by watching some tutorials on youtube. I follow the tutorials and try to add the recyclerview in the xml file. When I click the download button next to the recyclerview, the following message is shown:
"This operation requires the library androidx.recyclerview:recyclerview:+.
Problem: Inconsistencies in the existing project dependencies found.
Version incompatibility between:
- androidx.appcompat:appcompat:1.1.0#aar
and:
- androidx.core:core-ktx:1.1.0#aar
With the dependency:
- androidx.annotation::1.1.0
versus:
- androidx.annotation::2.0.0
The project may not compile after adding this library.
Would you like to add it anyway?"
If I choose OK and go ahead, the preview screen becomes grey.
What should I do to solve the problem?
The same problem occurs when I want to add the cardview in the xml file.
thanks in advance!!!!
The build.gradle is below:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.smartherd.msgshareapp"
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"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'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Just build the project again and manually refresh the layout. :)

Android ConstraintLayout baseline constraint not visible

Learning ConstraintLayout and running into this issue where the baseline constraint handle does not become visible even as a text view is selected.
Using Android Studio 3.4.1, Show All Constraints is selected.
gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 28
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'
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'
}
In the visual editor select the wanted TextView.
Right-click on it.
Select "Show Baseline"
Hover over the visual editor and click on the component to select. There you will see an "ab" button. Click on that.

when i new a project in android studio error found in priview Render problem

Problem:
Render problem
Failed to load AppCompat ActionBar with unknown error. Tip: Try to refresh the layout.
A lot of people said change theme Theme.AppCompat.Light.DarkActionBar to Base.Theme.AppCompat.Light.DarkActionBar but still not solved. Of course I don't want to to this every time when I start a new project.
This problem gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "three.my.test.newtextapplication"
minSdkVersion 23
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.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'
}
Just change the 28 SDK to 27 and use 27.1.1 dependencies. And if you still want to use 28 then use 28-rc1. Hope this helps you to solve the problem.

Categories

Resources