I'm working on an Android Studio project of which I write while constantly move back and forth from laptop to desktop using usb stick. There has been no problem for couple of months I tried this since Android Studio went stable, until today this message keeps showing up no matter how many times I sync the gradle:
Gradle files have changed since last project sync. A project sync may be necessary for the IDE to work properly.
Gradle Console indicates that the build is successful. I also tried cleaning and rebuilding the project, even reinstalling Android Studio, still the message pops out.
What seems to be the problem? Is it not recommended to write a project on multiple Android Studios?
Here's a look of my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.simplifyinc.prodigy"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "0.3.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'net.the4thdimension:audio-wife:1.0.3'
compile project('libraries:android-crop')
}
in build.gradle(module:app)
change
build tool,( in my case its 23.0.1)
targetSdkVersion (23) and
in dependency
compile version
("com.android.support:appcompat-v7:23.1.0")
to latest
This happens due to gradle updates
*****Check your PC date*****
You must check your PC or laptop date and time. Correct your date and time will resolve your issue.
each IDE(even if it is the same build number) uses its own metadata. an example would be the location of the Android sdk.when shuffling files between different systems, you would have to make sure that none of the system generated files are copied.
the safest way would be to delete the all the files and folders mentioned in the . gitignore file.
and as in this particular case, the .idea folder.
The modified date for some of my files were set to a future date/time (still havent figured out the cause). Updating the modified time of each file in the project using touch -mt YYYYMMDDhhmm ./* and then the same for those with a . prefix touch -mt YYYYMMDDhhmm ./.* fixed this for me.
this error had happened to me when I changed my computer time carelessly
configer my computer time,and reset the time,this error solved
this error happen when android studio 2.3.3 available and i ignore it, upgrade your android studio to 2.3.3
For Me Below Steps Worked:
1) Delete .idea folder
2) Delete build folder
3) opened each file mentioned in .ignore with notepad and add a space , remove a space and saved file again. this will not effects the file but the trick is notepad changes the Date modified attribute of file.
Related
I have updated from Android Studio 4.0 to 4.1. After the update I cannot build my application anymore which worked fine before the update.
When I build the project I am getting the following exception:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compressDebugAssets'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CompressAssetsWorkAction
my\application\path\app\build\intermediates\merged_assets\debug\out
The folder my\application\path\app\build\intermediates\merged_assets\debug\out is empty.
What I tried to do:
Clean and rebuild the project
delete the .gradle and the build folder and clean an rebuild the project
invalidate and restart Android studio
Increased the heap size in gradle.properties to: org.gradle.jvmargs=-Xmx4096m
Increased the compileSdkVersion and targetSdkVersion
Installed and updated the buildToolsVersion from 30.0.0 to 30.0.2
Added multiDexEnabled true to my config
My gradle configuration looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-R'
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "my.application.id"
minSdkVersion 23
targetSdkVersion 29
versionCode 2
versionName "1.1"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.room:room-runtime:2.2.5"
annotationProcessor "androidx.room:room-compiler:2.2.5"
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'androidx.multidex:multidex:2.0.1'
}
Guys, I am out of ideas as I am no expert when it comes to gradle. Help would be most appreciated.
I found a temporary solution in downgrading my Android Studio version to 4.0.2.
Additionally, I changed the Android gradle plugin version to 4.0.2 and the gradle version to 6.1.1 which I had installed before. You can do this under File -> Project Structure -> Project.
Now I am able to run my application again. I am aware that this is only a temporary solution but at least I can work again on my application.
I will try to install Android Studio 4.2 Canary 15 the next days and check, if this works for me. I let you know.
This is what usually works for me every time i make an update, I hope it works for you.
Sometimes gradle build fails because, downloading some dependencies required by gradle for a successful build are missing and need to be downloaded. So make sure your computer is online.
-> Click on gradle (right side of your android studio), then toggle the highlighted button in the pic below.
Make sure its not highlighted, Cause if it is highlighted that means gradle is offline (has no access to internet)
Then rebuild project to download the missing gradle dependencies.
I hope you find this useful.
this solution may help. I had problems with this error showing up and I had no idea why. As it turns out, I save my android projects to a USB stick. The USB stick is formatted using PAL. I reformatted using NTFS and the problem has gone.
I had a similar problem this morning after updating my Android studio. In my case, previous projects run well but if I create a new project and attempt to run, I will get the said error message. I changed the Android Gradle plugin version to 4.0.2 and the Gradle version to 6.1.1 from the project structure dialog and I was able to run the app successfully afterward.
I have this problem when I try to build apk with capacitor Ionic in Android Studio. My solution was:
First change the Android Gradle plugin in build.gradle to classpath 'com.android.tools.build:gradle:4.0.2' and in gradle-wrapper.properties change Gradle version to distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip and press Sync Now.
When gradle sync is finish, close Android Studio Editor and go to project folder and inside android delete .idea and .gradle folders. Next you need to open PowerSheel in this location and run the code .\gradlew clean.
Finally, you can open the project with android studio using in vs npx cap open android or as you want, wait for sync gradle and then you can build your apk.
Changing the location my projects from a FAT32 formatted drive to an NTFS drive solved the problem for me.
I had been working on Android Studio version 1.1. 2-3 days before, it asked for update to 1.2. I thought it was gonna get all the better. But, now I am facing the following problems:
Warning:The project encoding (windows-1252) does not match the encoding specified in the Gradle build files (UTF-8).
This can lead to serious bugs.
More Info...<br>Open File Encoding Settings
and,
This version of the rendering library is more recent than your version of Android Studio. Please update Android Studio
I have tried uninstalling-reinstalling it like 7 time already but problems don't go away. I have never messed up with Android Studio settings.
Why is this happening? and What should I do to resolve it? I am just enough desperate that I was gonna Format my computer but thats a mammoth task so I am asking here.
P.S: I tried changing the encoding but nothing works.
Thanks.
EDIT 1 : Following Sandspy's advice build.gradle contains the following with no support library.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.mankum93.geoquiz"
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'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
EDIT 2: Here is the problem still persisting:
EDIT 3: After changing from MNC to Android Lollipop.
EDIT 4: I guess I am gonna download the 1.2 stable binary and not update until 1.3 stable is released. If anyone solves this problem concretely please post the solution here.
For any reason, Android Studio generates the projects in windows-1252 enconding, but the IDE enconding still being UTF-8.
You can change it in File -> Settings -> Editor -> File encoding -> Project Encoding; like weston said in the last answer.
For reference, the same issue was answered in this sites:
https://stackoverflow.com/a/30012572
http://tools.android.com/knownissues/encoding
http://forums.bignerdranch.com/viewtopic.php?f=396&t=9107&start=20
Though not a solution to the problem, I have tried uninstalling-reinstalling Android 1.1.2, 1.2 again and again. I then tried tried Android 1.1. Now, everything is working perfectly.
So, I am saying is, people having this problem might have to rely on Android Studio 1.1 for now. I am posting it to tell you of a tricky step involved in thi process. If you have Android 1.2.1 or 1.2 installed, after the uninstallation of it, delete the following folder,
<Your-current-PC-user-Name>/.AndroidStudio or /.AndroidStudio11.2 and /.gradle before reinstallation of Android 1.1 otherwise problem will persist.
When you see this:
Click Open File Encoding Settings and change from windows-1252 to UTF-8:
I'm having some strange issue with Android Studio recently. I'm trying to build a project after few modification in code. But the APK got installed is of old code. (I found this by debugging. When I debugged it was going to empty lines) But all my latest code are saved and it's there. I have tried the following steps which I know.
Delete the build folders of Project and Module manually > Restart Studio > Clean Project > Rebuild Project
Restart Android Studio and (I don't know why I restarted but I did that too)
Invalidate and Cache Restart
At some point I found a issue in XML related to style attribute for button which was like style:attr/buttonBarButtonStyle I later corrected to style:"?android:attr/buttonBarButtonStyle"I hope this change is correct because it don't show any more error.
And finally it doesn't give me any error in stacktrace. Project always shows BUILD SUCCESSFUL
Nothing above helped me.
EDIT 1 : I have updated my Android Support Library to 22.1.1 latest version which released a couple of days ago
EDIT 2 : I uninstalled Android Studio. Deleted Android Studio related folders in C:\Program Files\Android\Android Studio and also deleted C:\Users\MyUserName\.android & .AndroidStudio & .gradle folders. And did fresh install of Android Studio. Later I imported a same project and build it. Again it happens in same way! I have also tried running the same project in other lap and it runs without any problem. I Don't know what else I'm missing here
EDIT 3 : Updating my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
signingConfigs {
debug {
storeFile file("./debugkeystore/MyAppDebug.keystore")
}
}
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 14
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'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:6.1.+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:support-v4:22.0.+'
compile 'com.android.support:cardview-v7:21.0.+'
}
I just again uninstalled AndroidStudio and clear the registery and made it like a fresh install for the 3rd time and I don't know how but this time it worked! But didn't get what exactly happened!
I solved it by rebuilding the project. Go to the build tab
you should configure Run/Debug Configuration again and add to "Before launch" section "Gradle-aware Make"
that's it
This is not a migrated project.
I've made a small project in android studio 1.0.2 with all the default settings. It was working well until I encountered a weird problem. It recently just fell apart - literally, nothing works and I don't even know what to look at for the issue.
Background
I had a strange problem with v21/something.xml where graddle cmplained about syntax error (it was complaining about lack of /. I saw it looks different ten other similar lines and corrected it to look like the others, but something (gradle script creator?) chaged it back to the form with syntax error.
Problem
I've found that similar issue is related to wrong sdk version, I've tried changing minSdkVersion to 21 (from 11) and updated gradle to see red marks pretty much everywhere.
THe puzzling thing is, that when I looked into the event log I saw this:
12:28:43 AssertionError: Already disposed: Module: 'app': Already disposed: Module: 'app'
12:28:43 All files are up-to-date
12:30:55 Project Sync
The project 'Yamba' is not a Gradle-based project
More Information about migrating to Gradle
Clearly the project stopped being a grale one - What a Terrible Failure...
In the project tree, the .idea directory is red and everything within it plus local.properties
All .java files have a red mark on them.
When I try to run the project, it opens edit configuration dialog and there is no module specified.
How can I find the error source, and more importantly how to fix it? I can upload any code you need - just tell me what is relevant here, as there are too many files to put them all and keep it readable.
the build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.asteroth.yamba"
minSdkVersion 21
targetSdkVersion 21
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:appcompat-v7:21.0.3'
}
EDIT:
I've made a new project under the same name, copied all the files over to it and it builds - something caused corruption in the actual project. I'll try to reproduce it
I want to build an app in Android Studio with the support library but I get the following error when adding the dependency for the support library:
Error:Failed to find: com.android.support:support-v4:19.1.0
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '20'
defaultConfig {
applicationId "sample.myapplication"
minSdkVersion 15
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:19.1.0'
}
I have downloaded the support library via the sdk manager.
Ok, found the problem. The Android support repository was missing. After installing and restarting Android Studio it worked.
If you are using Android Studio, then as an addition to changing the build.gradle file manually, you can also lookup the dependency via the library dependencies under the Project Structure menu item.
Double clicking that dependency will generate this line in build.gradle:
dependencies {
compile 'com.android.support:support-v13:+'
}
And also, if you are wondering what this library is about, it's described at the developer pages at developer.android.com; Support Library.
My Android Studio version is 1.1. I select tools->Android->SDK Manager, check the Android Support Library then click Install packages, solved this issue.
In my case the solution was as simple as running Build:Make Project. No amount of gradle syncing or clearing caches would do it. Of course, that required getting my project into a state where it would build successfully.
In my case I needed to add Google Maven repository.
It shows as part of the error in Android Studio and only needed to click on it to add itself.
Then Gradle built the project on its own.
Following the instruction here helped me. For whatever reason when I had to reinstall the latest version of android studio the initial download of the extras section android support library failed. I simply retried it. Followed the steps mentioned and verified it was added to the build.gradle file and did a rebuild project and good to go.
http://developer.android.com/tools/support-library/setup.html