Android Studio cannot resolve symbol 'TabLayout' - android

Cannot resolve symbol TabLayout ? How to clear this error? Please help me. I already imported import android.support.design.widget.TabLayout;

Had a similar problem, to fix this in Android Studio (AS) I went Build->Clean Project and AS sorted everything out. Make sure in your build.gradle file under dependencies that you have:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:your_api_version_number.0.0'
compile 'com.android.support:design:+'
}

I solved the issue Manually by adding the following two lines:
implementation 'com.android.support:support-v4:22.2.0'
implementation 'com.android.support:design:22.2.0'
under dependencies in \app\build.gradle worked for me.
Note: Your all the support libraries have to be the same version i.e. appcompat-v7 and support-v4 to same version e.g. 23.0.1; otherwise you can get this error
java.lang.NoClassDefFoundError: android.support.v7.internal.widget.TintManager`
after code build

Under Gradle Scripts,
Open build.gradle (Module: app)
Inside of dependencies add
compile 'com.android.support:design:25.3.1'
There may be a newer version of the library available, the android studio lint check may detect that.
The full dependencies area may look like this for reference. The above line is the only one I manually added.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
}
An above answer suggested adding
compile 'com.android.support:design:+'
Which is kind of dangerous because it always uses the latest library, you may have trouble isolating bugs with automatic library updates happening in the background.

Android Studio no longer uses "compile", they use "implementation".
Be sure to include the code below when you go to Build Gradle>dependencies{
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
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.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

For Android API Level 29+, add the following dependency in build.gradle (Module:app):
dependencies {
implementation 'com.google.android.material:material:1.0.0'
}
If there is a newer version available, Android Studio will prompt you to use the newest one.

I solve it by Open build.gradle (Module: app) and add
implementation 'com.android.support:design:+'

Related

Switching from 'compile' to 'implementation' gives DexPathList Error

I am trying to update my dependencies to use the new implementation/api spec instead of compile. This is for a general library I am writing which I then use in my app via jitpack.
When I make the simple switch from compile to implementation I get the following error (just the important bits) when using the library in my app:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bumptech/glide/request/RequestOptions;
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bumptech.glide.request.RequestOptions" on path: DexPathList
I have tried cleaning and rebuilding and it does not help. The second I switch back to compile calls everything works just fine.
I'll note that the library will build just fine in all cases.
The following usage works (though warns me that compile will be deprecated):
compile fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
compile 'com.github.ybq:Android-SpinKit:1.2.0'
compile 'io.reactivex.rxjava2:rxandroid:2.1.0'
compile 'androidx.appcompat:appcompat:1.0.2'
compile "com.github.bumptech.glide:glide:4.4.0"
compile 'androidx.recyclerview:recyclerview:1.0.0'
compile "com.github.chrisbanes:PhotoView:1.3.1"
compile 'com.google.android.material:material:1.0.0'
The following gives the above error (also gives the error if I use api instead of implementation):
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation "com.github.bumptech.glide:glide:4.4.0"
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation "com.github.chrisbanes:PhotoView:1.3.1"
implementation 'com.google.android.material:material:1.0.0'
I'll also add that if I just switch the glide to compile then it gives the same error but about a different dependency. Can anyone help me figure this out? I could just keep compile for now but I want to update this.
After hours of debugging I finally figured it out
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
Updating the maven gradle plugin in my library to 2.1 from 1.5 resolved the issue

Failed to resolve: firebaseui-android.internal:lintchecks:unspecified

I got message:
Failed to resolve: firebaseui-android.internal:lintchecks:unspecified
when I add implementation 'com.firebaseui:firebase-ui-auth:3.2.0' on dependencies.
How to solve them?
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.firebaseui:firebase-ui-auth:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
Update: Fixed in release 3.2.1.
This problem was logged as a FirebaseUI issue yesterday. The recommended workaround is:
compile('com.firebaseui:firebase-ui-auth:3.2.0') {
exclude module: 'lintchecks'
}
I had also the exact problem as you do, 2 hours ago and I fixed it by changing this line of code:
implementation 'com.firebaseui:firebase-ui-auth:3.2.0'
with
implementation 'com.firebaseui:firebase-ui-auth:3.1.3'
See here. The last version 3.2.0 did not work for me either.

Unable to use Snackbar after updating Android Studio

I have recently updated my Android Studio version to 2.3
I am working on a project now and I've noticed that I am unable to import Snackbar class. I never had that problem before.
I can use it by adding compile 'com.nispok:snackbar:2.6.1' and I can import it then, but I don't think I should have to do that instead of just using Android's android.support.design.widget.Snackbar;
This is are my dependencies from build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
I have also tried to play around with DataBinding concept in my project but I don't think this could cause that issue?
Thank you.
You are missing the compile 'com.android.support:design:25.2.0' in your dependencies. As the library is not added you are unable to get the Snackbar class.

Android Studio Rendering Problems: android.support.design.widget.TabLayout class not found

When I add TabLayout inside my xml file it shows this error.
I also have these dependencies.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
}
See Code here
Add this dependency in gradle
compile 'com.android.support:design:23.1.0'
You can try to build it or change preview Android version in here Preview Android Version

Roboelectric 3.0 testing fragments

I am new to Roboelectric testing.
I am trying to follow this post to test fragments. I am using following as dependency
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile "org.robolectric:robolectric:3.0"
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:support-v4:22.1.0'
compile 'com.google.android.gms:play-services:7.5.0'
}
But this import is giving me compilation issues, and I am not able to resolve the symbol SupportFragmentTestUtil to start with. Kindly guide me what I am missing??
org.robolectric.shadows.support.v4.SupportFragmentTestUtil
You need to add the dependency for v4 shadows support. Add this in your dependency file.
testCompile "org.robolectric:shadows-support-v4:3.0"

Categories

Resources