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
Related
I had my project working fine in Android Studio but then:
I upgraded to Windows 10
That broke my java install, but I have that
working as well now (removed everything then reinstalled)
I now also updaded to latest stable Android Studio
But when I try build my project now, I get 100+ errors in this:
W:\android-studio-projects\mycustomer\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\22.2.0\res\values-v21\values-v21.xml
Where each error/line is like this:
Error:(2) Error retrieving parent for item: No resource found that
matches the given name 'android:TextAppearance.Material.Inverse'.
...
Someone asked how my app/build.gradle looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:17'
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "dk.company.app"
minSdkVersion 9
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.github.PhilJay:MPAndroidChart:v2.0.8'
compile 'com.android.support:appcompat-v7:22.2.1'
}
I just inserted the 4rth line in dependencies
compile 'com.android.support:appcompat-v7:22.2.1'
However, it has never been necessary in the past though and inserting it has not fixed my problem. (Why is it suddenly necessary anyhow. Could I maybe remove the dependency - that would fix the issue as well?)
...
Something else that I find peculiar, but probably happens because the project never compiles correct, is that this code:
import dk.company.app.R;
always highlights "R" in red - i.e.cannot resolve symbol 'R'
However, my guess is that it never got as far as generating the file, but stopped when encountering the other appcompat compile errors
...
I can see there are some known similar problems to this:
https://code.google.com/p/android/issues/detail?id=183122
https://medium.com/#Wingnut/installing-android-studio-and-an-ensuing-rabbit-hole-ac3d9a0d3115
However, the solutions proposed. I have removed API 22 and API 23 all places in Sdk manager and file system I could fine. I have changed build tools and appcompa version to 21.1.2
Nothing worked sofar
There's a couple things you can do in attempt to solve this:
Clean project option in Build
Rebuild (not build) project option in Build
Invalidate caches / Restart option in File
Try these, it's a glitch with Android Studio where it doesn't compile everything sometimes.
The com.android.support:appcompat-v7:22.2.1 dependency requires you to compile your project with at least API Version 22 (5.1 Lolipop).
You're currently targeting and compiling using API Version 17 (4.2 Jelly Bean). You can still leave the targetSdkVersion as 17 (if you want) but you must compile with API Version 22+.
Try changing:
compileSdkVersion 'Google Inc.:Google APIs:17'
to:
compileSdkVersion 22
Note: You may also need to download the API Version 22 platform.
Edit: I see you've updated your question that you've attempted to use the v7:21.x.x appcompat library instead. This would require you compile using at least API Level 21 compileSdkVersion 21.
I have gotten this error quite a few times. I compiled a list in this answer of every way I've ever gotten it working again.
EDIT: Just thought of another one that is more likely to be relevant to what you're describing. If you had been compiling against SDK 17, and when you reinstalled Java you upgraded to Java 8, this may cause incompatibilities. I believe only SDKs greater than 20 can compile against Java 8. Also, moving from SDK 17 to 20+ may break your styles, which will cause your xml files to be invalid, which will prevent R from building. Look in res/values/styles and see if it's failing to find your style. If so, change it to a valid style for your new SDK, clean and build.
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
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.
I am going to start develop application for fire TV i can create an application using Eclipse successfully, But when i try the same procedure to create new application which compile with Firetv SDK got some Gradle error on android studio.. i am stuck with this issues for around one week.
The error is Gradle app neame project refresh failed:
Unexpected lock protocol found in lock file. Expected 3, found 0.
Gradle settings
I searched lot about this error in google but cant get any solution
Sorry for my bad English.
My even log says:
Gradle 'Test' project refresh failed:
Unexpected lock protocol found in lock file. Expected 3, found 0.
Gradle settings
My build gradle
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 17
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
My case, delete ~/.gradle/ and suddenly all working well again.
good luck!
Invalidate Caches And Restart Also Works. Try It Out By Going
To File and selecting Invalidate caches and restart
Just go to Android Studio -> File -> Close project. After closing the project,reopen it afresh. This solved the problem for me.
I couldn't understand about ~/.gradle/ folder... but now I got it
and solved! delete here folder!