I've been using the android.support.v7.widget package -- specifically the RecyclerView class (among others but this is where the problem is).
It was working fine until earlier today it randomly seems to default to an earlier version of the package now. I say that because:
When I try calling myRecyclerView.addOnScrollListener(myScrollListener), myRecyclerView.getChildAdapterPosition(myView) etc Android Studio gives the compile error Cannot resolve method ....
If I change it to myRecyclerView.setOnScrollListener(myScrollListener) (ie use set instead of add), it works fine and does not show the deprecated error, which it should because the method is deprecated.
I don't know why it's showing errors now when I've been using and have been able to compile with these methods earlier -- it seems as though it's using an earlier version of android.support.v7.widget library but I have no idea why it would or how to fix it...
edit: my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.myapp.app"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.1'
compile 'com.github.rey5137:material:1.1.1'
compile 'com.android.support:design:22.2.0'
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile 'com.rengwuxian.materialedittext:library:2.1.3'
}
I am not sure, How are you able to import it, But if you want to use RecyclerView, you need to add its dependency, i.e. compile 'com.android.support:recyclerview-v7:22.2.0'
I don't see if you have added RecyclerView dependency to your gradle script. Also, keep in mind, it doesn't come with appcompat package.
Related
I'm using Android Studio Beta 6, and I've added the RecyclerView support lib to the end of my build.gradle. My app is already running fine, I just need to use the RecyclerView now.
Here's build.gradle:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
addCustomFieldsToBuildConfig(release)
addCustomFieldsToBuildConfig(debug)
}
}
dependencies {
// ...
compile 'joda-time:joda-time:2.1'
compile 'com.google.android.gms:play-services-ads:+'
compile 'com.google.android.gms:play-services-analytics:+'
compile 'com.android.support:support-v13:21+'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile files('libs/com_nineoldandroids.jar')
compile files('libs/comscore.jar')
compile files('libs/crittercism_v2_1_7_crashonly.jar')
compile files('libs/urbanairship-lib-1.0.1.jar')
compile files('libs/adobeMobileLibrary-4.8.1.jar')
compile "commons-io:commons-io:2.4"
compile 'org.jsoup:jsoup:1.8.3'
// I WANT TO ADD THESE:
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.android.support:recyclerview-v7:21.+'
}
I've tried specific versions of RecyclerView such as '21.0.2' but they all result in the same issue. I ask Android Studio to sync the gradle settings, and there are no errors.
But as you can see, I can't autocomplete the v7 after support:
In the event that this will help someone in a similar situation with Android Studio, but I had to go to Build -> Make Project before it was able to resolve references to the RecyclerView class.
I am following a guide on using the Recycler View, I having trouble with the part of declaring the dependency and installing the RecyclerView into Android Studio.
I added the RecyclerView to my xml file and declared the dependency in build.gradle(below)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.ryde.chris.ryde"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.supportrecyclerview-v7:23.0.0'
}
I rebuilt the app and tried installing the Recycler View repo. When installing, I ran into the same exact issue that this user did.
I took a look at the answer on that thread. I chose to use RecyclerView v 23.0.0 and made sure that I compiled with api version 23 (compileSdkVersion 23 in build.gradle). Using the AVD manager, I also made sure that my support library for api version 23 was installed and updated
Does anyone know why I am still getting this issue? Internet is working fine (this to be specific)
Change
compile 'com.android.supportrecyclerview-v7:23.0.0'
to
compile 'com.android.support:recyclerview-v7:23.0.0'
Use the new version:
compile 'com.android.support:recyclerview-v7:23.1.1'
I'm hoping someone might shed some light on this issue. I am trying to change the support library versions from:
compile 'com.android.support:support-annotations:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:support-v13:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
to
compile 'com.android.support:support-annotations:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
What usually seems like a simple minor upgrade has caused me the entire day. Basically upon updating the gradle.build file, I sync -> clean, and there appears a bunch of Cannot Resolve Symbol errors appearing on the IDE for classes from the support library.
What's further interesting about this is that if I try to run the code on my phone through adb, despite AS showing up as "Cannot resolve symbol", it runs perfectly fine on my phone.
Among the things I've tried:
Clean / Rebuild
Invalidate cache / restart
Delete all the .iml files and the .idea folder
Reinstalling of Android Studio, reimport of project
Rebooting
Digging further into the build directory, they are similar in the sense that both
build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\jars\classes.jar
and
build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\jars\classes.jar
were generated respectively. What's different is that in AS, for the previous version, the "classes.jar" can be opened in AS where as with the new version, they cannot be opened in AS.
I feel that I have pretty much exhausted all available options so if anyone can shed some light on how to resolve this, I would really much appreciate it.
My full gradle.build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.XXX"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.1.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':XXX', configuration: 'android-endpoints')
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.4'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.balysv:material-ripple:1.0.2'
compile 'net.sf.flexjson:flexjson:3.3'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.google.android.gms:play-services-ads:8.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.android.support:support-annotations:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:support-v13:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
}
I have finally solved:
First of all, I updated the gradle plugin.
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
Then just Build->Clean project and everything works again.
I think I have solved this problem guys. Go to the main module in your project, it's usually have the name app.
Then go to > Open Module Settings > in Properties change the Build Tools Version to 23.0.1.
Then to make sure open the build.gradle file, and change compileSDKVersion & buildToolsVersion to 23 and 23.0.1 respectively.
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "id.web.twoh"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
You should also make sure that all modules in your project have the compileSdkVersion and buildToolsVersion begin with 23, as you will use the 23th version of the support library.
I know it's late but I had a similar issue. It turned out that the issue was caused by the Data binding library. I had an error in the code that referenced in an invalid reference in the generated binding class. My layout file defined a webview with id webview but in the code I referenced it as webView. After correcting the error and cleaning and doing full rebuild Android Studio started recogninsing all the packages and seeing support libraries.
I had exactly the same problem, and to solve it I have just changed the BuildDebug Configuration spinner to MainActivity :
I solved my problem by changing the Run/Debug Configuration spinner to MainActivity (instead of app[androidDepedencies]) in the ToolBar...
I have changed my appcompat library from version v7:21 to v7:19.1
i have fixed all the related issue and i downgraded the target sdk from 21 to 19 and every things worked but when i try to build to device i get
No resource found error in app compact v7:21 which is located in
app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/res/values-v21/values-v21.xml
i tried to clean the project my project and i used gradlew/clean with no success
my question if I'm using app compact v7:19 why i find app compact v7:21 in my exploded-arr folder?
this is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1"
defaultConfig {
applicationId "appname"
minSdkVersion 17
targetSdkVersion 19
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':bounceScroller')
compile project(':SwipeMenu')
compile project(':indicator')
compile project(':BetterSpinner')
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
compile 'com.edmodo:cropper:1.0.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.leocardz:aelv:1.1#aar'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.google.android.gms:play-services-ads:7.8.0'
compile 'com.google.android.gms:play-services-identity:7.8.0'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.creativeelites:androidexternalfilewriter:1.4'
compile 'com.lifeofcoding:cacheutilslibrary:1.0.0#aar'
compile 'com.google.code.gson:gson:2.2.2'
}
Sometimes gradle doesn't do what you would like it to - such as remove unused cached files if they are not in use on the project. Of course, those might be useful later, so...
Just delete the "intermediaries" folder. It will be recreated on your next build, and your build will take longer the first time you run it, but the problem should go away. You're essentially deleting the cache.
You may have other cached files that you need to remove as well, but that depends on settings in your environment.
EDIT:
You can also try to clear the gradle cache and the intermediaries folder. See this reference on how to clear cache.
How to clear gradle cache?
I try to add this lib (https://github.com/daimajia/AndroidImageSlider) to my project. I added the compile library in my gradle file, but i get an error :
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.pp.myapp"
minSdkVersion 16
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'com.iangclifton.android:floatlabel:1.0'
compile 'com.google.android.gms:play-services:5.0.89'
compile "com.android.support:support-v4:+"
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.0.9#aar'
}
And i get this error :
Error:Module version com.android.support:support-v13:13.0.0 depends on libraries but is not a library itself
Try adding this dependency:
compile 'com.android.support:support-v13:19.0.+'
You have to install the Android Support Library from the SDK, too.
I got the same error with an oauth library. It was fixed after a while when, tired of implementing new changes to the build.gradle like changing the support libraries, I discarded the changes on the file (via Sourcetree). It synchronized and automatically got fixed.
(Android Studio) It's a kind of magic.