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.
Related
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. :)
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.
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:
I am new in creating library from android studio. I have been reading this tutorial in developers website. So to try it out I have created a new project and without doing anything I edited the app level build.gradle file and here is how it looks like:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 15
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'
}
Now when I am trying to build an apk(which is supposed to build aar file) isn't building anything as I cant see any confirmation message like something when I build an apk nor can't I find anything inside app/build/outputs folder..
Where am I going wrong? Is there anything that I am understanding wrong in the tutorial?
Here is the project structure - screen shot
I have looked at numerous sites and the suggestions provided here at Stack Overflow. Everything works fine with my Android Studio, except the design view does not display anything. I can drag and drop widgets or modify the XML code by hand and the text gets updated fine, but the changes just don't register on the design or blueprint. I have tried deleting and reinstalling the IDE, changing the SDK version, doing build--> clean, resetting the cache, and adding dependencies. Below is my build.gradle Anyone with a critical eye have suggestions? I don't know what I'm doing.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.mydrinkmixer.somerestaurant.mydrinkmixer"
minSdkVersion 15
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"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
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'
}