I am using some plugin actionbarpulltorefresh, but in my code PullToRefreshLayout is not resolved by the ide. Here's my build.gradle file, the problem is that I can't find any source file of this plugin, nothing in the .gradle directory
I have some build.gradle file this
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}
android {
compileSdkVersion 18
buildToolsVersion '18'
defaultConfig {
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
Edit : when I put
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout;
private PullToRefreshLayout mPullToRefreshLayout;
I get the message can not resolve symbol PullToRefreshLayout.
I am using sat version intelliJ on which android studio is based
You'll have better luck if you upgrade to new versions of everything:
Android Studio 0.4.3.
Android Gradle plugin 0.8. You'll have to edit the classpath in your build.gradle to:
classpath 'com.android.tools.build:gradle:0.8.+'
Gradle 1.10. You'll have to edit the distributionUrl in your gradle/wrapper/gradle-wrapper.properties to:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
Download the 19.0.1 Android SDK Build Tools in the SDK Manager and instuct the build to use them with this in your build.gradle:
buildToolsVersion '19.0.1'
There's a bug that was fixed in Android Studio 0.4.3 that I think is the cause of it not seeing the classes in your actionbarpulltorefresh library; the new version of the plugin and Gradle will be necessary for your project to work in 0.4.3. If you upgrade Android Studio it should detect the old versions of the plugin and Gradle and offer to change them for you, but if it doesn't, then you can edit by hand. It won't offer to update the build tools version; you'll have to do that yourself.
Related
The Android studio ask me to update the gradle version to 4.4 and gradle build tool version to 3.1.2.
After the update, The whole android studio shows red lines in file, when I hover my cursor on these error it says "cannot resolve symbol" but compiles with no error i.e., build is successful.Click here to see red lines in java files
and Here are the gradle app and project files.
//Build.gradle(project)
//Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
url 'https://maven.fabric.io/public'
}
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'io.fabric.tools:gradle:1.25.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com/'
}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and
//build.gradle(module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.developers.paras.droidwatch"
minSdkVersion 19
targetSdkVersion 27
versionCode 9
versionName "9.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
android.defaultConfig.vectorDrawables.useSupportLibrary = true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:27.1.1'
compile 'com.android.support:customtabs:27.1.1'
compile 'com.android.support.constraint:constraint-layout:1.1.0'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:support-v4:27.1.1'
compile 'com.google.android.gms:play-services-ads:15.0.1'
compile 'com.google.firebase:firebase-core:15.0.2'
compile 'com.crashlytics.sdk.android:crashlytics:2.9.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
Things I have already tried.
Clean and Rebuild.
Invalidate Cache and Restart.
Updating gradle version to 4.9.
Setting local gradle for the project.
See my gradle logs here https://drive.google.com/open?id=18bFZdkWX4AFPfpmfjvN1t80WpVRpiHWs
See even release build is generated after these errors. Release apk generated
Update : Recently after Reinstalling Studio, I've created a new project and everything works fine. No errors for "cannot resolve symbol".
not the most graceful solution in the world but deleting and re-cloning the project was the fastest way to resolve this for me.
if you're not using git... well. now is a good time to start.
I tried deleting and re-syncing all the various config files and it didn't do anything.
I got into similar situation: upgraded Gradle to 4.4, then opened a former porject which had been built with Gradle 3.1.2.
Android Studio noticed it and generously offered:
To take advantage of all the latest features (such as Instant Run), improvements and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.1.2 and Gradle to version 4.4.
When I choose to update, I got the red underlines showing errors everywhere in MainActivity.java, however the project was building and runnig perfectly.
I also tried to rebuild and to invalidate cache & restart, but had no success.
For me, editing the build.gradle (module:app) file helped.
When I modified both compileSdkVersion and targetSdkVersion to the latest (27) and changed the version number of line implementation 'com.android.support:appcompat-v7:2x.x.x' under dependencies to the latest, then resynced, the red lines suddenly disappeared from MainActivity.java and everything became normal.
Maybe not the fiddling with sdk version numbers are important here, but to force a proper gradle resync.
Please note also, that since Gradle 3.4, under dependencies in build.gradle file some configuration words changed: compile, testCompile, androidTestCompile, testApi, androidTestApi become obsolete and should be replaced with implementation or api.
You can find more on this issue here: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration?utm_source=android-studio#new_configurations and a proper explanation on the difference between choosing implementation or api here: https://medium.com/mindorks/implementation-vs-api-in-gradle-3-0-494c817a6fa
I generated a Gradle build file from an Eclipse project, then ran gradle build in the source root dir, which generated the following error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/me/src/myproject/build.gradle' line: 11
* What went wrong:
A problem occurred evaluating project ':src:myproject'.
> Failed to apply plugin [id 'com.android.application']
> Gradle version 1.10 is required. Current version is 2.10. If using the gradle wrapper, try editing the distributionUrl in /home/me/src/myproject/gradle/wrapper/gradle-wrapper.properties to gradle-1.10-all.zip
This is the auto-generated build.gradle:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':tools:android-sdk-linux_86:extras:android:support:v7:appcompat')
}
android {
compileSdkVersion 25
buildToolsVersion "23.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
On the other hand, this project builds without any issues.
I’ve tried copying the buildscript block as well as any missing sub-blocks of android over, as well as commenting out the top-level dependencies block, to no avail.
If it matters, OS is Ubuntu 16.04 (64-bit), gradle 2.10.
What gives?
I finally got it to build using Gradle Wrapper.
Since gradle wrapper would also fail with the same error message (have 2.10, want 1.10), I just copied over gradlew, gradlew.bat and the gradle subdir from another project that I’ve previously built successfully.
gradlew build would still complain about the version, so I edited the version in gradle-wrapper.properties as directed by the error message.
Then some modifications to build.gradle (not all of them may be necessary):
Add a new block at the top:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
This will, among others, specify JCenter as a repository for dependencies. For Maven Central specify mavenCentral() instead of jcenter(), which will work as well.
Modify the dependencies block: Since we’re pulling the Android support libraries in from a repository, disable local builds. Delete the following line:
compile project(':tools:android-sdk-linux_86:extras:android:support:v7:appcompat')
If you don’t have any local jars to include, drop the other line as well (in which case you can eliminate the entire section). I had one single jar to include (besides appcompat), so I kept the line and changed *.jar to the name of the jar I needed. (Alternatively, delete duplicate jars from your libs dir, but that will break ant builds directly from Eclipse.)
In the android block, add the following children:
defaultConfig {
minSdkVersion 11
targetSdkVersion 23
}
lintOptions {
abortOnError false
}
dependencies {
compile 'com.android.support:support-v4:23.1.+'
compile 'com.android.support:appcompat-v7:23.1.+'
}
API versions in defaultConfig should match those in your app manifest.
lintOptions is important if your project contains some non-critical issues (unused declarations, use of deprecated APIs and the like), else these will cause build to fail.
dependencies may vary depending on the libraries you’re including via JCenter. I noticed appcompat-v7 v23.2 and higher would give me compile errors (which is likely a separate issue), so I stuck with the last ones that worked.
With all of these, the project finally builds. So much about Google maintaining backward compatibility...
My task is to build an apk file using gradle wrapper via command line. I have a project in Android Studio 2.2.3, it has a line in build.gradle file classpath 'com.android.tools.build:gradle:2.2.3', which should mean, that it is using gradle version 2.2.3. But when I call gradlew command from the project folder, there is always the same error: Unsupported major.minor version 52.0
I've used gradlew -v to recognize my gradle version, it is now 2.2.1. Though when I manually change gradle version in build.gradle file from 2.2.3 to 2.2.1 I still get the same error.
I checked the folder containing gradle on my computer. It has gradle version 2.14.1.
I tried:
changing JDK path from 1.7 to 1.8 (JAVA_HOME variable)
manually changing JDK location at Project Structure -> SDK Location settings
in gradle settings: switching between using default gradle wrapper and local gradle distribution.
Interesting thing is that when I change gradle version in build.gradle to 1.5.0 the version error disappears, but I can no longer make any builds(it becomes unable to merge several jar files into one apk file)
What is this version hell and how do I get rid of this error?
EDIT #1:
My /gradle/wrapper/gradle-wrapper.properties content is:
#Fri Oct 21 12:53:56 EEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
EDIT #2:
I figured out that gradle versions are the same. So what JDK and JRE version should I use and how do I update them? Simply downloading into Java folder and changing JDK location in Project Structure didn't help.
EDIT #3:
My build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My project-level build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.test.test"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:23.4.0'
compile "com.android.support:support-v4:23.4.0"
compile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
SOLUTION:
I needed to update targetSdkVersion and all dependencies to version 25 and set JAVA_HOME to jdk 1.8. Thanks, Abhishek Aryan
Gradle version is different from Android Plugin for Gradle version.
This is Android Plugin for Gradle with version
classpath 'com.android.tools.build:gradle:2.2.3'
And gradle with version
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
I just updated Android Studio to version 0.3.2. My project uses Gradle version 1.8.
On the picture below you can see that it is configured in gradle and Android Studio resolver http-async package but gradle fails with Gradle: package com.loopj.android.http does not exist
I tried already
to remove android-async-http and adding it as Library again,
to include fileTree(...) in gradle configuration file,
Rebuilt project but nothing helped
Though if absolute path is set gradle works just fine.
Gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:13.0.0'
compile 'com.android.support:support-v13:13.0.0'
compile 'com.google.android.gms:play-services:3.1.36'
compile files("libs/android-async-http-1.4.4.jar")
}
Can anyone help me with this?
Try to move the libs folder at the same level of src folder.
Android Studio have just released 0.3.7, which claims to have solved a lot of gradle issues such as adding .jar libraries
http://tools.android.com/recent
Hopefully this will help you!
I am trying to add v7 support for action bars to my project and followed the steps on the android dev site but still doesn't work...
In my gradle file I have
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile "com.android.support:appcompat-v7:18.0.+"
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
just like it says to do but when I try to import the class or use the resource, it isn't found.
I also downloaded the latest support library and repository in the sdk manager as well.
Am I missing a step or setting?
I fixed it.... All I needed to do was run
./gradlew clean build
in the root of my project. Android studio wasn't updating the gradle so it didn't include the external libraries.