Views stopped showing on Design Mode in Android Studio out of the blue (including the "hello world" textView). I haven't updated anything or changed anything.
I tried the following solutions:
(changing the theme) This view is not constrained android studio. I can not see the button even if I use Infer Constraints
inferring constraints.
(can't find the link) but the answer marked as correct said my SDK is corrupt -> updating it didn't work.
I'm suspecting Gradle is the culprit somehow, so here's the app's build script (a brand new project):
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.cc.take6"
minSdkVersion 28
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 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
my android Studio is version: 3.6.3.
Any ideas? thank you in advance.
Make sure you are using the latest stable version of Android Studio and all related tools
Update your project to use latest version of Gradle and everything
File -> Invalidate Caches and Restart
Build -> Clean Project
Build -> Rebuild Project
Run
I fixed the problem by changing the version of contraintLayout implementation that I was using. I added to the file build.gradle(:app):
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
Related
I am trying to develop an SFTP client using sshj on Android studio such that the App can connect securely to the server using SFTP over ssh. The code was running fine, but when I added the "sshj-0.10.0" module, it gives me this complicated error.
The "sshj-0.10.0" module is needed to run server code using net library as below:
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.sftp.SFTPClient;
I added the module the project and configured it in the dependencies in build.gradel of the app as shown below:
What I have tried so far (but not limited to):
1- Clean Project then Rebuild Project - failed
2- Invalidate Caches / Restart - failed
3- Delete .gradle and .idea from my root project- failed
4- Added
android {
defaultConfig {
multiDexEnabled true
}
}
and
dependencies {// Multidex
implementation 'com.android.support:multidex:1.0.3'
implementation project(path: ':sshj-0.10.0')
}
No solution was worked with me.
Here is my build.gradle(:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.mohsenali.autosen"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.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'
//TedPermission
implementation 'gun0912.ted:tedpermission:1.0.3'
implementation files('D:/SKKU_PhD/Android/workspace_2018_projects/AutoSen/app/libs/commons-net-3.7.1.jar')
// Multidex
implementation 'com.android.support:multidex:1.0.3'
implementation project(path: ':sshj-0.10.0')
}
I know that this kind of error is popular but I tried many possible solutions available on SO since two days ago but none of them has helped me. So please don't mark it duplicated, maybe someone could help. Thanks.
Finally, I solved this error bu creating "libs" folder in the root of "app" project, and added the .jar library to it. After that I updated the code in "build.gradle(:app)" by adding this line: "implementation files('path to/app/libs/jsch-0.1.55.jar')".
I have updated my android build.gradle to latest version now i am getting an error.
I have searched answers regarding this here(stackover flow),but none work for me .
my build.gradle code is:--->
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.parse.starter"
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.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
when i click on "sync now" then the error appears as:--->
This project uses AndroidX Dependencies,but the 'android.useAndroidX' property is not enabled.
After searching some answers here(stackover flow) .i created a file 'gradle.property' from File>new>Files(named as gradle.property) and added codes on it as:--->
org.gradle.jvmargs=-Xmx2048m
android.useAndroidX=true
android.enableJetifier=true
After doing this when i click again on "sync now".then again the same error appears (This project uses AndroidX Dependencies,but the 'android.useAndroidX' property is not enabled.)
I dont know how to fix this issue.
please Help
thankyou.
Try this solution go to :
Refactor -> Refactor this -> Migrate to Androidx -> click migrate , then a pop up message will show up to ask you if you want to save a copy of the project by ticking that checkbox ( up to you ) --> then do refactor
You might have migrated to android x manually
Try using built in migrator
https://developer.android.com/jetpack/androidx/migrate
Just right click , then go to refractor> migrate to AndroidX
I'm new to Android development and inherited a project from an old collegue. At some point in time, I changed something in the project structure. I'm not sure what I changed that triggered these errors. However, now intellisense shows all kind of errors: Ex. on import android.content.Intent; it says Cannot resolve symbol 'Intent'.
Now, the project still builds and runs without a problem, however, everywhere in the project are red squiggly lines and autocomplete doesn't work.
I have tried all i could find on this problem (invalidate cache / deleting files / reimport project / etc) The only thing I found to work is changing the API version to 27, in which case every intellisense warning dissappears, although the project breaks, because it uses version 28 stuff.
Currently, the app module has compileSdkVersion 28 and targetSdkVerion 27. Changing both to 27 resolves the intellisense, but breaks the projct, changing both to 28 (or 29) doesn't resolve anything.
It feels like i might need to update something else?
*update as requested by haresh, *
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "nl.app.ofme"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi", "armeabi-v7a"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion = '28.0.3'
//Used to get clear warning details about deprecated methods
allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.1.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.squareup.okio:okio:1.15.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.android.volley:volley:1.1.0#aar'
implementation 'com.google.firebase:firebase-analytics:17.2.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'
}
}
dependencies {
implementation 'com.google.firebase:firebase-messaging:20.0.1'
}
apply plugin: 'com.google.gms.google-services'
In Android Studio, go to File -> Invalidate Caches / Restart ...
Try to use updated version for all of your module and project level library.
File -> Snyc Project with gradle files.
Migrate with androidx. Refactor -> Migrate to Android
In Android Studio, go to File -> Invalidate Caches / Restart
This are the all things you can try.
It's been a while I'm trying to run/code a RecyclerView example, with no success though. I guess it has something to do with the RecyclerView version used in dependencies and the Android versions my project is using.
Currently, I'm trying to run this example here.
It doesn't mention what are the compileSdkVersion, minSdkVersion and so on.
Anyway, here's my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.deluxe.example"
minSdkVersion 24
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.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
Also in this example, the Adapter imports android.support.v7.widget.RecyclerView, for which I get an error: Cannot resolve symbol v7. So, Android suggested importing androidx.recyclerview.widget.RecyclerView;
Issue: my project doesn't load the RecyclerView in the MainActivity - it throws an exception:
Error inflating class android.support.v7.widget.RecyclerView
for which although there're similar questions here and here and here, I couldn't solve my issue.
I'm new to Android Studio, so can anyone suggest what should I change in order to run this Recycler/CardView example? I've tried several examples already, but wasn't able to run any of them - recent and older ones.
I'm trying to run using Android Nougat(7.0) and upper, but it's not mandatory. And my Android Studio version is 3.5.1
Because you're using Androidx (good), then you need to import the corresponding artifacts:
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta04' (or whatever latest version exists)
And then in all the places where you reference RecyclerView, (hint: use Android studio "find" and search for the term recyclerview to find and evaluate all references and places where it's mentioned), and ensure you are referencing the new artifacts, e.g.:
import androidx.recyclerview.widget.RecyclerView in code and
<androidx.recyclerview.widget.RecyclerView ... in XML.
While you are at it, remove
implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
And if you can, replace:
implementation 'com.android.support:cardview-v7:28.0.0'
with:
implementation "com.google.android.material:material:1.1.0-alpha10"
And use:
<com.google.android.material.card.MaterialCardView
in your XMLs.
I've been working with Firebase Database.The code was working fine for Firebase Authentication but showed this error message when added Firebase Database.
Incorrect value for field 'Signature': value is 662655099 but 67324752 expected.
Following is the gradle script:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.sudhanshujaisani.mywhatsapp"
minSdkVersion 21
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:support-v4: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.android.support:design:27.1.1'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
}
Thanks in advance.
I don't really know what causes this error but I had it too and I figured out (after some research) that it's something going on with Instant Run. It hasn't got anything to do with firebase, but I think it's something about Gradle and importing packages.
Anyway, I figured disabling Instant Run as a simple workaround and it worked! :)
In Android Studio:
File -> Settings (or press Ctrl+Alt+S).
Build, Execution, Deployment -> Instant Run (on the left panel).
Uncheck the first checkbox "Enable Instant Run to hot swap code/resource changes on deploy (default enabled)".
If you actually need Instant Run, this workaround won't help. I'm still trying to find the actual solution.
Invalidate Cache & Restart didn't work for me.
Try,
Build -> Clean Project
Build -> Rebuild project
File -> Invalidate Caches/Restart -
Update your android sdk, partial installations cause this problem.