This question already has answers here:
Android Studio 3.1 "Run" not compiling code
(5 answers)
Closed 4 years ago.
I have a weird problem with Android Studio. When I Run my app there are no gradlebuild and etc. just installing app and launch activity which means nothing what I changed in the code will be changed in my apk.
Have you any idea why is this happening?
project level gradle:
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath 'com.google.gms:google-services:3.2.0'
classpath "io.realm:realm-gradle-plugin:5.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app level gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
android {
compileSdkVersion 26
defaultConfig {
applicationId ""
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
realm {
syncEnabled = true;
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
}
apply plugin: 'com.google.gms.google-services'
You have to fix the Run process in Android Studio.
Look at your main toolbar and find this box:
Click the box and select Edit Configurations....
Make sure the window has the following items in Before launch section:
Gradle-aware Make
Instant App Provision
Click OK.
Run your app.
Try this: File menu -> Invalidate Caches/ Restart. I think it will resolve your problem.
There's been an issue in the 3.1.0 build tools upgrade of Android Studio. Follow these steps to resolve it.
Select Run and click Edit Configurations
Make sure, Gradle-aware Make is Added in TaskList or not. If not then:
click +
select Gradle-aware Make
Leave the task empty and select OK
NOTE: Make sure Gradle-aware Make is before Instant App Provision
Try to following instruction it will surely help you. I already face same problem before couple of month.
* Update ADB in your Android Studio.
* Uninstall application.
* Restart adb start-server.
* Restart you testing device.
Related
After opening an older project for the first time after a few weeks/months (very busy with work) Android Studio asked me to upgrade to the latest gradle plugin.
Gradle Upgrade promt
I didn't really think anything of it and hit "Update". After Gradle finished updating and syncing I noticed that most of my layout and java class files vanished. They're simply gone.
However, in my project's directory a folder called "projectFilesBackup" appeared. I assume that restoring the backup contained in this folder might bring my missing files back.
projectFilesBackup Folder
So my question is: Does anyone know how I actually tell Android Studio to restore to the backup? It only contains an ".idea" folder which contains "workspace.xml". Any help would be greatly appreciated.
I've already tried using "Local History" to undo any changes done on the day of the Gradle Update as detailed in this SO post.
Edit:
As requested my build.gradle files:
// 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:2.2.1'
classpath "io.realm:realm-gradle-plugin:1.2.0"
// 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
}
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.tools.awesome.cs.grademanager"
minSdkVersion 23
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'io.realm:android-adapters:1.3.0'
}
Change the realm-gradle-plugin to the most dated one and see if it brings up the files again.
classpath "io.realm:realm-gradle-plugin:2.0.2"
I noticed that Firebase APIs have upgraded from v 9.0.0 to v 9.0.1 and so decided to change that.
However it is not getting noticed.
Here is the Error in Gradle Logcat
Error:(25, 13) Failed to resolve: com.google.firebase:firebase-messaging:9.0.1
Error:(26, 13) Failed to resolve: com.google.firebase:firebase-core:9.0.1
And here are my Gradle Files
Build.Gradle-> App
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.lifeline.applicationgreat"
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.google.firebase:firebase-core:9.0.1'
}
apply plugin: 'com.google.gms.google-services'
Build.Gradle-> Project
// 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:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
// 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
}
Can Anyone tell whats the Error or if I am Missing anything.
Also Is there any requirement of Firebase-core for Cloud Messaging?
Thanks
You have to update/install Google Repository, revision 27
Check this answer: firebase setup on android
I had the same issue with "com.google.firebase:firebase-ads:9.0.1", what I did was install from de SDK Manager Google Repository Extra.
You'll need to go to the Android SDK manager and check for updates - you should see an update to the Google Play services SDK which will resolve these dependencies.
For mac os users, a part from updating your SDK, if you have installed the ADK with and without brew, be sure to check that the path for your ADK in Android studio is the correct one. My problem was that android studio reverted to the old path on its own.
I am quite new to Android development and trying to write some test code. I have downloaded Android Studio 1.3 version and created testapp. I am trying to add com.facebook.android:facebook-android-sdk:4.1.0 depedency but somehow it's not getting downloaded.
Here is Project level build.gradle file.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}
Here is Module level build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.testapp"
minSdkVersion 19
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.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:appcompat-v7:22.2.1'
}
After reading other posts on similar topics I also confirmed that Gradle > Global Gradle settings > Offline work is not checked. Still somehow facebook depedency is not getting downloaded.
Any suggestions what could be the issue? Appreciate any pointers.
Thanks.
In your build.gradle you have to add
repositories {
jcenter()
}
It this way gradle knows where are the dependencies to download.
It is somenthing different from the repositories inside the buildscript block.
Otherwise you can add in the top-level build.gradle file:
allprojects {
repositories {
jcenter()
}
}
In this case, the repository block is valid for all modules in the project.
Could you post the error AndroidStudio is showing? (check on the Gradle Console, on the Run section and Android Monitor section)
One possible option that comes to my mind is that you don't have the lastest Android Support repository / Google repository installed: Check for updates on your Android SDK Manager.
Gradle gets stuck when I try to build on the task [:android:generateDebugSources].
I've left it running for hours without a successful build.
I've tried it in Android Studio 1.0.0, 0.8.1, with Gradle versions 2.1.1, 1.12, 1.14, Android plugin versions 0.12.+ and 0.14.4 using the default wrapper as well as local distributions. I've reinstalled Android Studio and rebooted without any luck. Also tried File --> invalidate caches/Restart.
Here is my android package's build.gradle:
buildscript {
repositories
{
maven { url 'https://maven.fabric.io/repo' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/repo' }
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
minSdkVersion 11
targetSdkVersion 21
versionCode 13
versionName "onBoarding"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-query-full.0.26.8.jar')
compile files('libs/gson-2.3.jar')
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.google.android.gms:play-services:6.1.71'
}
And then my project-level gradle.build file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Any advice greatly appreciated.
Got it! Changing the buildToolsVersion from 21.1.1 to 20 yielded a successful build.
You can also, just install the correct version of the tools.
I know this is an old question, but I spent a lot of time in this problem and read at least 30 answers until I found out what was hapenning.
I constantly got a message that another aplication was locking a file that Android-Studio needed to complete gradle building. Finally, I found out that it was Avast. So I simply deactivated it and the build finished successfully, but it still took a long time (about 10 minutes).
Tried below option and it worked!
Add below properties to your .gradle file
org.gradle.daemon=true
org.gradle.parallel=true
Set SLAVE_AAPT_TIMEOUT environment variable to 30 in windows and restart your system.
Second solution credit goes to semuzaboi.
Gradle no longer finds dependencies declared in the build.gradle. Everything was working fine and today when I open Android Studio I get an error :
Error:Failed to find: com.readystatesoftware.systembartint:systembartint:1.0.3
The library referenced is SystemBarTint. I had the library work previously using the same build.gradle file but now it no longer works.
My app/build.gradle looks like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.adnan.systembartintdemo"
minSdkVersion 19
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.readystatesoftware.systembartint:systembartint:1.0.3'
}
My root/build.gradle looks like this :
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
Any ideas what I am doing wrong here? Thanks !
Edit : Tried importing a project which I work on daily at my work, it fails to find any dependencies in that project either. Tried re installing Android Studio, still the same error
Ok finally got this fixed.The problem was weird, for some reason it was trying to pick up a local offline copy of the dependency, I went to Settings -> Compiler -> Gradle -> Enabled offline Work and disabled it again. Save and Apply changes.
And now it works !