Why is app:assembleDebug called twice? - android

Why is app:assembleDebug called twice during my builds?
My app consists of two modules, the application module app and a library module commons. When I click ‘run’ in Android Studio to deploy the app on the device, I see this happening:
The bottom bar says Gradle build using tasks: [:app:assembleDebug, :commons:assembleDebug]. The blue progress bar is slowly filled. No output in the Gradle Console.
At 100% progress, I get the notification Compilation completed succesfully in 3m. Yay! At this point I expect the app to be installed.
The bar is stuck at 100%. For a moment I read something like executing post-compile tasks, and then Executing tasks: [:app:assembleDebug].
:app:assembleDebug is called again and takes some other 3 mins, while we are stuck at 100%. This time the Gradle Console logs output.
The app is installed.
Why is this? Not using Instant Run, though the same thing applies.
gradle.properties
org.gradle.jvmargs=-Xmx2560M
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.daemon=true
project level build.grade
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
ext {
compileSdkVersion = 25
buildToolsVersion = "25.0.2"
minSdkVersion = 15
targetSdkVersion = 25
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app module build.grade
apply plugin: 'com.android.application'
android {
dexOptions {
preDexLibraries true
javaMaxHeapSize "2g"
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.package.id"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
signingConfig signingConfigs.release_config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
}
debug {
minifyEnabled false
shrinkResources false
}
}
productFlavors {}
}
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.4.3'
compile 'com.google.android.gms:play-services-maps:9.2.1'
compile 'com.google.android.gms:play-services-appinvite:9.2.1'
compile 'com.google.android.gms:play-services-location:9.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.2.1'
compile 'com.google.android.gms:play-services-places:9.2.1'
compile ('com.facebook.android:facebook-android-sdk:4.16.1') {
exclude module: 'bolts-tasks'
}
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:preference-v14:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.parse.bolts:bolts-tasks:1.4.0'
compile 'com.parse:parse-android:1.14.0'
compile ('com.parse:parseui-widget-android:0.0.1') {
exclude module: 'parse-android'
}
compile project(':commons')
}
apply plugin: 'com.google.gms.google-services’

OK, somehow I had this in my run configuration:
After removing Make, I am back to sane compilation behavior. I wonder why I had that extra make though.

Related

Dex Error while building the project

I am getting the following error when I try to build my project. This error occurs when I was trying to add JavaMail api in my project.
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.persi.eatery"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/mailcap.default'
exclude 'META-INF/mimetypes.default'
}
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
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.android.support:design:26.1.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.sun.mail:android-mail:1.6.1'
implementation 'com.sun.mail:android-activation:1.6.1'
implementation project(':library')
}
apply plugin: 'com.google.gms.google-services'
My library gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.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
}
P.S I have already tried Clean project followed by rebuild project as suggested in other answers but its still not working.Thanks in advance
Unable to merge dex
You have a dependencies conflict. Try to see your dependencies via command ./gradlew app:dependencies (Details here ). And you will see the next situation:
As you can see android-mail depends on android-activation. I think you don't need to use the line implementation 'com.sun.mail:android-activation:1.6.1'
P.S. For debugging builds you can use the next flag "--stacktrace". Then you can see more information about your issue.

Failed to sync gradle project after adding Mapbox navigation SDK package.Its showing some irrelavant error [duplicate]

This question already has answers here:
Failed to resolve: com.android.support:cardview-v7:26.0.0 android
(26 answers)
Closed 5 years ago.
Here is my gradle file. I am using Appcompat 25.3.1 version, but the error is on Appcompat 26.1.0. This error goes off when navigation SDK package is removed. I dont understand what is happening. Any help is greatly appreciated.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.aadhilahmed.test3"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories{
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.2' //error is here
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
And this is my error message:
Failed to resolve: com.android.support.appcompat-v7:26.1.0
Error:- Install repository and sync project.
Open file.
Show in Project Structure Dialog.
Even clicking on Install repository and sync project does absolutely nothing.
Add this inside your repositories block in your project level build.gradle file:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
This is the best way to do it.
In your root level gradle.build use below
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and in your gradle-wrapper.properties file change the wrapper version as below
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
also in your app level build.gradle make sure you are using 26 vesion as below
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.xxxx"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Android apps will run on API 25 only

This is very strange now. No matter what project it is, my android app wont run on any other roms but API 25 based only.The default hello world app even wont run on any other API.
Basically the apk installation fails on every other rom other than the ones that are nouugat based.
My minsdkversion is 21 though
Here is the build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.rishav.basictest"
minSdkVersion 21
targetSdkVersion 25
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'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.4.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
Build.gradle(Project):-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
// 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
}
I met the same problem..
In Android Studio 2.3 and higher, There is Instant Run which may affect your code.
Disable Instant Run
File -> Settings -> Build, Execution, Deployment -> Instant Run
In my case it was working perfect,i hope may this will help you.

Twilio: Video call connecting device with computer through ngrok

I follow the [Twilio quickstart-android] [1]: https://www.twilio.com/docs/api/video/guide/quickstart-android
when i put the identity that i give at this url : htp://0fd251a7.ngrok.io/video-quickstart-php-master/token.php inside poupup (invite participant)
and when i click send at the end of the screen show onLocalvideoTrackAdded and a black small squere at the end and closed about 30-40 sec.
at the url http://0fd251a7.ngrok.io/video-quickstart-php-master/ my camera is turn on and dont get any invitation from the request that i send from app.
and is a problem that compile 'com.twilio:conversations-android:0.12.2' is at build.gradle(Module:app) in dependencies and not at build.gradle(project:video-quickstart-php-master_test)
// 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.2'
}
}
allprojects {
repositories {
jcenter()
}
}
/* i have comment this becouse give me an error at android studio that the build file my be a missing a gradle plugin. */
//compile 'com.twilio:conversations-android:0.12.2'
this is build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.twilio.conversations.quickstart"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.koushikdutta.ion:ion:2.1.7'
compile 'com.twilio:conversations-android:0.12.2'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}

Android studio - finished with non-zero exit value 1 exception

I have added Fabric to my application from Android studio via Fabric plugin, after that I could not run my application. It shows following error while running the project.
Error message:
Error:Execution failed for task ':qApp:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1
build.gradle file after included Fabric:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.+'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.qapp"
minSdkVersion 14
targetSdkVersion 21
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':facebookSDK')
compile project(':payPalDemo1')
compile project(':uberLibrary')
compile project(':bSLibrary')
compile project(':pullToRefresh')
compile project(':androidmapsutils')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:multidex:1.0.0'
compile files('libs/android-async-http-1.4.6.jar')
compile files('libs/cardio.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
compile files('libs/UserFormValidation.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
}
It was working fine before adding Fabric, how I can resolve this issue? please help me. I am running on Ubuntu Machine.
Try to add multiDexEnabled true in your gradle file as below:
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
...
}
After that clean and rebuild your project.
It's work for me.I hope its helps you.
You app has crossed the dex limit of 65k methods so you need to enable multidex in your app.
add
compile 'com.android.support:multidex:1.0.1'
to gradle and also add multidex:true
defaultConfig {
multiDexEnabled true
}
Also extend your application class with MultiDexApplication.this and this.
*note - you might wanna remove playservices with more bifurcated version like this link explains, to avoid multidex issues.

Categories

Resources