Android Studio project build issue - android

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

Related

How to use Google Play Services 7.3.0 on AndroidStudio?

I've updated my Android SDK and also the PlayServices Library. Nothing seems to work right now.
The import com.google.android.*; does not exists, and I've added the 'compile' lines on the Gradle File.
Have someone experienced this? How can I solve this?
EDIT
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 14
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:22.1.1'
compile 'com.google.code.gson:gson:2.3'
compile 'org.roboguice:roboguice:3.0.1'
compile 'com.google.android.gms:play-services:7.3.0'
}
That's the Gradle File for a Module.
If you use Android Studio and want to use the latest Google libraries via Gradle dependency, you will have to update the
You can do this via Tools -> Android -> SDK Manager -> You have to update the stuff under Extras
Also make sure that you are not using the Offline Mode of Gradle. You can find this option via (I did this on a Mac) Android Studio -> Preferences -> Gradle -> (Global Gradle Settings) Offline Work
Make sure this option is not checked.
Something which was mentioned by #CommonsWare already (and i add it just to sum up this answer) is to sync the project via the Gradle files. You can do this via the toolbar as seen here:
Or via the menu Tools > Android > Sync Project with Gradle Files
If nothing of the above is working for you, it would be really helpful if you can try to build the project via the command line or the terminal with the following command:
gradle clean build --debug
and then post the output here. It will hopefully show why it can't resolve the library.
Try Tools > Android > Sync Project with Gradle Files and see if that clears up your problem. There's a bug where Android Studio does not always warn you to do this with the yellow banner on the editor.

"Gradle files have changed since last project sync." message always shows up

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.

project stopped being gradle project. NOT MIGRATING

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

Android Studio: Failed to find: 'com.android.support:support-v4:19.1.0'

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

How to start develop application for fire os in android studio IDE

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!

Categories

Resources