Gradle is taking a long time to build - android

All of a sudden my gradle build has become really really slow seams like its doing some extra work that it didn't used to do here is a picture from build :
as you can see there are a lot of tasks here it used to be build in like 10 seconds now it takes minutes to build whats wrong with it? it writes things in the bottom bar like resolving some libraries for kotlin and doing something related to caching "variant attribute matching cache" here is the picture :
i was trying to activate the annotation processor that it happend here is my gradle codes:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.moein.volley_download_kotlin"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions{
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
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.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso- core:3.0.2'
implementation 'com.tonyodev.fetch2downloaders:fetch2downloaders:2.0.0-RC21'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.dagger:dagger:2.13'
annotationProcessor 'com.google.dagger:dagger-compiler:2.13'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.13'
}
and the other code
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}

In gradle setting check work offline.
Clean and rebuild your project.
In gradle.properties in Gradle scripts directory(i.e., ~/.gradle/gradle.properties), add
org.gradle.parallel=true
org.gradle.daemon=true
This settings have helped me a lot.

Related

How to use Picasso library with Androidx?

I have an One year old code, which I worked so hard on, this code uses picasso library in some places to download images and use them. Today I try to improve my code, migrate to androidx and upgrade Gradle to the latest version, but it doesn't seem to sync gradle file anymore, when I comment the implementation for picasso library, the sync goes smoothly again.
Google recommends migrating to androidx to be able to serve the latest android versions, the latest play services and jetpack libraries. What is the problem? and how it can be solved?
This is my Gradle app level file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.ramikabbani.sheikhsouk"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
// Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.google.android.material:material:1.1.0'
//
}
and this is my top level project gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
// 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
}
This is the old project app level gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.dalilukom.dalilukom"
minSdkVersion 19
targetSdkVersion 29
versionCode 21
versionName "1.21"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.bumptech.glide:glide:3.8.0'
//implementation 'com.android.volley:volley:1.1.1'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
// implementation 'com.amitshekhar.android:android-networking:1.0.2'
// implementation 'com.android.support:design:26.1.0'
// implementation 'com.android.support:appcompat-v7:27.1.1'
// implementation 'com.android.support:design:27.1.1'
//implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
and this is the top level gradle file for the old project too:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
// 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
}
Just migrate to androidx and get the Picasso dependency for androidx on your grade file. You should be fine
Just found a workaround.
In build.gradle (project:..) , of the project gradle file ,downgrade plugin to '7.2.1' and recompile.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
}
and it works , seems like it unsupported on later versions.
But I think you should change the file gradle.properties( Project properties ) under android.useAndroidX=true
Put:
android.enableJetifier=true
putting whole file content of gradle.properties( Project properties )
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
android.nonTransitiveRClass=true

Error in implementing Firebase admin sdk in android studio

When I am implementing firebase admin libraries
it is showing error I have mentioned after my app and project level gradle files below.
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
configurations {
all*.exclude module: 'support-v4' // This removes all other versions of `support-v4` if gets duplicated from all the artifacts.
}
defaultConfig {
applicationId "com.example.trolificnss"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.firebaseui:firebase-ui-auth:6.2.0"
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-admin:6.12.2'
implementation 'com.google.firebase:firebase-analytics:17.2.3'
implementation 'com.google.firebase:firebase-firestore:21.4.1'
implementation 'com.firebaseui:firebase-ui-database:6.2.0'
implementation 'com.firebaseui:firebase-ui-storage:6.2.0'
implementation "com.google.firebase:firebase-firestore:21.4.1"
implementation "com.firebaseui:firebase-ui-firestore:6.2.0"
implementation 'com.firebaseui:firebase-ui-database:6.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.firebaseui:firebase-ui-firestore:6.2.0'
implementation 'com.google.firebase:firebase-storage:19.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.firebaseui:firebase-ui-auth:6.2.0'
implementation 'net.schmizz:sshj:0.10.0'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.google.gms:google-services:4.2.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
}
Below is the error message,
In project 'app' a resolved Google Play services library dependency
depends on another at an exact version (e.g. "[1.21. 0]", but isn't
being resolved to that version. Behavior exhibited by the library will
be unknown.
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}
---------------------------------------------------------------------------
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "org.solamour.myserver"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
resConfigs "auto"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// Conflict with dependency 'com.google.code.findbugs:jsr305' in project ':app'.
// Resolved versions for app (1.3.9) and test app (2.0.1) differ.
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:2.0.1' // Or "1.3.9".
}
}
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'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.firebase:firebase-admin:4.1.6'
implementation 'com.android.support:multidex:1.0.2'
}
take a look at the javadoc for FirebaseOptions Builder in the Android client library:
com.google.firebase.FirebaseOptions.Builder
Now look at the same class from the java Admin SDK (note the URL is different):
com.google.firebase.FirebaseOptions.Builder
Remove this:
implementation 'com.google.firebase:firebase-admin:6.12.2'
You can't effectvely use the Firebase Admin SDK in an Android app. It's meant only for code that runs on backend servers and desktop machines.
Also, you should always make sure your Android client library dependencies are at the current versions shown in the release notes. Your Firebase-UI library versions should also match with the other Firebase libraries.

Could not find the AndroidManifest.xml file, using generation folder after Android Annotations

I can't run my project after adding the #EActivity Annotation to my class.
This is my Gradle Project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my Gradle Module:app
apply plugin: 'com.android.application'
def AAVersion = '4.2.0'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.tasks"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:support-annotations:28.0.0'
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation "org.androidannotations:androidannotations-api:$AAVersion"
}
After I added the Android Annotations in my Gradle I noticed that my AndroidMannifest didn't get automatically modified (Missing the _ in the activity), and when I add that manually it gets highlighted in red.
If I run the project normally (Without modifying the AndroidMannifest or changing the class to Annotations) it will run normally.
If I add the annotations and modify the Manifest I'll receive the error:
error: Could not find the AndroidManifest.xml file, using generation
folder
[C:\Users\Asusc\AndroidStudioProjects\Tasks\app\build\generated\source\apt\debug])
Any idea what I might be doing wrong?
In my case, adding this to build.gradle fixed it:
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
arguments = ["androidManifestFile": "$projectDir/src/main/AndroidManifest.xml".toString()]
}
}
}
}
You should update to AndroidAnnotations 4.6.0 . This version has Android Gradle Plugin 3.3.+ support.
If you are using AndroidAnnotations 4.6.0 with Android Gradle Plugin 3.5.+, you can downgrade the Android Gradle Plugin version to 3.4.1 to fix.
classpath 'com.android.tools.build:gradle:3.4.1'

Unable to install Navigation in android

I am trying to install the latest release Navigation in Architecture components .
i am following this document Tutorial link
When i am trying to sync it is giving error .
Could not find androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.pom
https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.jar
https://jcenter.bintray.com/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.pom
https://jcenter.bintray.com/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.jar
Required by:
project :
Module Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.ard.navigationapp"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
def nav_version = "1.0.0-alpha01"
implementation 'android.arch.navigation:navigation-fragment:$nav_version' // use -ktx for Kotlin
implementation 'android.arch.navigation:navigation-ui:$nav_version' // use -ktx for Kotlin
// optional - Test helpers
androidTestImplementation 'android.arch.navigation:navigation-testing:$nav_version' // use -ktx for Kotlin
}
apply plugin: 'androidx.navigation.safeargs'
Project Gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "androidx.navigation:safe-args-gradle-plugin:1.0.0-alph
a01"
// 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
}
That artifact does not seem to exist, based on what's in https://maven.google.com right now. Try android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01 instead. See also this issue.
Try to add
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01"
instead of
classpath "androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01"
If you're not concerned with type-safety of argument, you can skip the Safe args part and you will be good to go with Navigation Component.

Failed to resolve support-v4 27.1.0 dependency in Gradle

I am trying to build an app on Android 27 and facing issues when I add android com.android.support:support-v4:27.1.0 and com.google.firebase:firebase-messaging:12.0.1 dependencies.
My Project Gradle file looks like this -
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My App build.gradle file looks like this -
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.project.webinar"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.android.gms:play-services-base:12.0.1'
implementation 'com.android.support:support-v13:27.1.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.google.android.gms:play-services-places:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
}
apply plugin: 'com.google.gms.google-services'
I am getting the following error while building on Android Studio 3.1.0 -
Can someone please help me how to get support-v4:27.1.0 to work for my app?
it seems your gradle is offline or you have enable proxy

Categories

Resources