Android studio intellisense cannot resolve symbol on import - android

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.

Related

views don't shows on design mode in Android Studio

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'

Error: transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

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')".

This project uses AndroidX Dependencies,but the 'android.useAndroidX' property is not enabled

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

Incorrect value for field 'Signature': value is 662655099 but 67324752 expected

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.

Error in building gradle - com.google.android.gms:play-services-basement is being requested by various other libraries

I am trying to integrate Facebook sign in feature to my android app using Firebase-UI library. I am following this tutorial - https://firebase.google.com/docs/auth/android/firebaseui?authuser=0
But I am getting below error while trying to build gradle:
The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 16.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
Below is my app level build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "company.com.mygame"
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'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.0'
implementation 'com.facebook.android:facebook-android-sdk:4.37.0'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.firebaseui:firebase-ui-auth:4.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'
}
apply plugin: 'com.google.gms.google-services'
I saw below links -
com.google.android.gms:play-services-measurement-base is being requested by various other libraries
https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/37
But then I get this error -
Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.firebaseui:firebase-ui-auth:4.2.0] C:\Users\me\.gradle\caches\transforms-1\files-1.1\firebase-ui-auth-4.2.0.aar\xxx\AndroidManifest.xml as the library might be using APIs not available in 15
Suggestion: use a compatible library with a minSdk of at most 15,
or increase this project's minSdk version to at least 16,
or use tools:overrideLibrary="com.firebase.ui.auth" to force usage (may lead to runtime failures)
But the issue is still not fixed. I have just started learning android, not sure what am I missing.
I had the same issue
Just make sure that you have the latest versions of all the dependencies. I used the current versions for Firebase core and auth.
You can get the latest versions from here .
Using the latest version at current point of time:
in app/build.gradle :
dependencies {
...
// Add these code
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.0'
}
in android/build.gradle :
buildscript {
ext {
...
minSdkVersion = 16
...
}
}
Your error says : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 and your build.gradle as minSdkVersion 15. Try to change it to 16 and see if that works for you.
All the best for learning android. May the force be with you.
Over and out,
Aashish

Categories

Resources