I am using android studio.This is the error suddenly I got when building gradle. Earlier it was working correctly. I close the android studio and re-build the gradle. But doesn't fix the error. I clean and rebuild the gradle.
Can you solve the problem.
Error:org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter$FileCollectionSnapshotImpl cannot be cast to org.gradle.api.internal.changedetection.state.OutputFilesCollectionSnapshotter$OutputFilesSnapshot
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Following display my build.gradle information
classpath 'com.android.tools.build:gradle:1.5.0'
pply plugin: 'com.android.application'
compileSdkVersion 23
buildToolsVersion "23.0.2"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
Gradle may be not found. Try to change gradle version and update it with your gradle version like in project :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
and this one in module of gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.yourproject"
minSdkVersion 15
targetSdkVersion 23
versionCode 14
versionName '1.4'
}
Related
Recently dove into the world of React-Native and got roadblocked immediately. Bought a course from Udemy called The Complete React Native and Redux Course and got stuck trying to compile my first application.
I've tried a bunch of different solutions and have gone through a variety of different errors so its come to the point where I have to make my first stackoverflow post. Going to post a bunch of my current settings below as well as the error im receiving.
Error
My Configuations
Java SDK/JRE's I have installed
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_151
ANDROID_HOME = C:\Users\Danny\AppData\Local\Android\sdk
PATH = C:\Users\Danny\AppData\Roaming\cabal\bin;C:\Users\Danny\AppData\Roaming\npm;
React Native Properties
React-Native Version
Android Studio Properties
Project Structure
SDK/JDK Location
Installed SDK Tools
Installed SDK's
gradle-wrapper.properties
#Mon Dec 11 21:41:46 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-rc-2-
all.zip
build.gradle (Module:app)
android {
compileSdkVersion 23
buildToolsVersion '25.0.1'
defaultConfig {
applicationId "com.albums"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
build.gradle (Project: albums)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
}
}
In the course im using the instructor says to use the NEXUS 5 API 23, incase that helps. Gradle builds within Android Studio no errors.
Thanks for any and all help
Solved.
Deleted my project, recreated it with react-native init ProjectName, ran AVD, compiled project through terminal. I think I altered too many configurations in my old one and needed to recreate it.
My Gradle
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.tester.us_site"
minSdkVersion 17
//noinspection GradleCompatible
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
After compilation, I get this error
Information:Gradle tasks [:app:assembleDebug]
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: org.gradle.tooling.BuildException: com.android.dx.cf.code.SimException: default or static interface method used without --min-sdk-version >= 24
Information:BUILD FAILED in 40s
Information:1 error
Information:0 warnings
Information:See complete output in console
As I understand, this error says that in order to run the project it is necessary to specify min sdk 26.
But what about Android 5.0 6.0 7.0?
## Gradle Build ##
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You can try to upgrade it to the latest android-specific build
implementation 'com.google.guava:guava:23.0-android'
This fixed the error for me
I Change Guava 21 on 22.
and add
force 'com.google.code.findbugs:jsr305:1.3.9'
This is working. All thx))
I have a project in Eclipse and I export to gradle project and open in Android Studio when I sync project I get
Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
This is my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.smok.maps"
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'joda-time:joda-time:2.3'
compile files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
compile files('libs/osmbonuspack_v4.9.jar')
compile files('libs/osmdroid-android-4.2-javadoc.jar')
compile files('libs/osmdroid-android-4.2.jar')
compile files('libs/slf4j-android-1.5.8.jar')
}
Well, I got this issue because my project was imported from Eclipse to Android Studio and dependencies were missing in gradle.
I got rid of it after adding
useLibrary 'org.apache.http.legacy'
in
defaultConfig {
}
below
targetSdkVersion 25
After, this I had to set
minSdkVersion 9
Also, I added following lines
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
above
defaultConfig {
//code snippet
}
So, that it looks like,
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
defaultConfig {
applicationId "xxx.xxxx.xxxx.xxxx"
minSdkVersion 9
targetSdkVersion 25
useLibrary 'org.apache.http.legacy'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_5
targetCompatibility JavaVersion.VERSION_1_5
}
//remaining code snippet
//.....
}
//remaining code snippet
//.....
}
#tompok, you are getting this error maybe due to jar files you are using in dependencies may not be there.
Instead Google for their gradle dependencies and place the package name in place of path like it is in first line:
compile 'com.android.support:support-v4:19.1.0'
Replace remaining dependencies in the above format.
Hope, it will help you.
______________________________________
EDIT:
You are facing this problem since you are using buildToolsVersion 25.0.2 whereas library you are using is compile 'com.android.support:support-v4:19.1.0'
Just change it to compile 'com.android.support:support-v4:25.0.2' and your issue will be solved.
Ask if you face any other issue else accept it as answer so it may help others.
Try code on your module build.gradle:
android {
// ...
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
// ...
}
It means Android studio DO NOT check PNG strictly.
I met this problem, after draw the left and bottom stratch line for .9
.png then it ok. Good luck.
most of the time is a corrupt PNG image added recently to the project which cause this error.
Check the git log and replace the file.
Sometimes menu : File > InvalidateCaches/Restart also helps
Well, I didn't got the solution when I used in android studio 3.1
android {
// ...
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
// ...
}
Actually I'm in the process of importing the eclipse project to latest android studio. I spend around three day in searching for this specific error.
Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error:Execution failed for task ':app:mergeDebugResources'.
I found some references from the following links...
why i get Some file crunching failed after i rename drawable file to .9.png?
Gradle throw app:mergedebugresources exception
After that I searched In the drawable for the images with the extension image_name.9.png. and renamed it to image_name.png. After that this error got disappeared. Again this worked for my project, still not sure about other causes for this problem. I hope that this may be useful for someone!
Invalidate the caches then close the project and import it again.
I have imported a android source code from Github and while syncing the gradle process I have got an error
Error:(1, 0) Plugin with id 'com.android.application' not found.
Open File
This is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "activities.safepassbeta"
minSdkVersion 16
targetSdkVersion 19
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.android.support:support-v4:20.0.0'
}
Try changing the classpath in the top level build.gradle file to 'com.android.tools.build:gradle:2.0.0-beta7' and the distributionUrl value in gradle-wrapper.properties file to https://services.gradle.org/distributions/gradle-2.10-all.zip.
Make sure that in the settings for gradle in the 'Build, execution and deployment' section, you have set the preference to 'Use default gradle wrapper'.
As the other answer described, try changing the classpath in the top level build.gradle file. The file you show is the application build.gradle, not the top level build.gradle file. For Android Studio 3, you can try using 'com.android.tools.build:gradle:3.0.1'. The problem is that the gradle dependency is not downloading properly, usually because of improper settings for the url to use to download gradle. This is a common problem. If the problem persists look into solutions for how to set up gradle, such as Manually install Gradle and use it in Android Studio
A quick-and-easy fix is to look at your previous projects which work on your IDE, look at what version of gradle they are using. If you use that version of gradle in this project it will most likely work.
However, the 'proper' solution is to set up the distributionUrl properly. Worst come to worst, if that does not work, you could also try manually downloading Gradle to use it in your project.
I want to import a library project into my app but whenever I try to do so , Android Studio doesn't recognise it
It also gives me errors in build.gradle ..
The Library is : PagerSlidingTabStrip ....
Here are some pictures :
I have been trying to make it work for 3 days so far !!
Please Help Me :)
EDIT:
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:19.0.0'
}
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 8
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
EDIT2 :
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':Sahertoday'.
> Could not resolve all dependencies for configuration ':Sahertoday:_debugCompile'.
> Could not find com.astuetz:pagerslidingtabstrip:1.0.1.
Required by:
Saher-3:Sahertoday:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
First of all, you can add this dependency to your project, without compiling the lib locally.
dependencies {
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}
Otherwise if you would like to compile this lib locally, you have to define these keys in gradle.properties in the root.
ANDROID_BUILD_TARGET_SDK_VERSION=19
ANDROID_BUILD_TOOLS_VERSION=19
ANDROID_BUILD_SDK_VERSION=19
EDIT
There is also a GUI way for doing this. It is accessed by selecting the module facebook in the project tree and pressing f4. Also you can just right-click the facebook and go to Open Module Settings near the bottom. It is shown in the pictures. The numbers in the picture are top sdk version at the time of writing.
There is a simpler solution.
The constants like ANDROID_BUILD_SDK_VERSION can be replaced with normal version "numbers". So instead of
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 8
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
..file can look like this:
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
}
Go the facebook folder which you have imported in your project. Copy the gradle.properties file and paste in into your facebook module.It will remove the errors.
For those who ran into same problems while adding libraries and still can't get it work. The following local include of the .aar file worked for me:
Just download the .aar file from the maven repo manually.
In Android Studio go to File -> new Module -> import .JAR or
.AAR package and select your downloaded .aar file.
Android Studio does the rest (in the build.gradle) for you. Maybe clean and rebuild your project.
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 4
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'
}