Gradle Sync taking a lot of time - android

Gradle SYNC is taking more than 3hrs. The code seems to be Syncing forever (i have tried rebooting Android Studio but it does not help), I am observing this after updating Gradle and Android studio yesterday. It is stuck in Gradle Sync Condfigure build and taking forever to complete and finish
I have tried following tricks and techniques:
1) Updated Android Studio to 3.5
2) Tried File-->Settings-->Gradle-->Offline Work
3) Internet connection superfast
4) Not behind any Proxy or VPN
apply plugin: 'com.android.application'
//***********************************************************************************************//
def IOTHUB_DEVICE_CONNECTION_STRING_ENV_VAR_NAME = project.hasProperty('DeviceConnectionString') ? '"'+project.property('DeviceConnectionString')+'"' : '"Define Device Connection"'
def STRING='String'
//***********************************************************************************************//
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.iothub.azure.microsoft.com.androidsample"
minSdkVersion 24
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
each {
//buildTypes.mBuildConfigFields 'DATATYPE','VARIABLE',|"GRADLE VARIABLE|"'
buildConfigField STRING, 'DeviceConnectionString', IOTHUB_DEVICE_CONNECTION_STRING_ENV_VAR_NAME
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude "META-INF/MSFTSIG.SF"
exclude "META-INF/MSFTSIG.RSA"
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'thirdpartynotice.txt'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation ('com.microsoft.azure.sdk.iot:iot-device-client:1.14.2'){
exclude module: 'azure-storage'
}
implementation ('com.microsoft.azure.android:azure-storage-android:2.0.0#aar')
implementation ('org.apache.commons:commons-lang3:3.6')
}
repositories {
mavenCentral()
}

Related

Android: Multiple dex files define Lcom/google/android/gms/location/places/zza;

I can't stop getting this error every time, and I don't know what caused it and how I can solve it:
Multiple dex files define Lcom/google/android/gms/location/places/zza;
I think it may have to do with google-services, but I'm not entirely sure.
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.xxxx.xxxx"
minSdkVersion 14
targetSdkVersion 28
versionCode 10173
versionName "4.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// Fixes "Duplicate files copied in APK" build bug
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
// Pushy SDK
implementation 'com.google.firebase:firebase-messaging:17.5.0'
compile 'me.pushy:sdk:1.0.43'
// AppCompat v7 Dependency
compile 'com.android.support:appcompat-v7:28.0.0'
compile 'com.google.android.gms:play-services-maps:16.1.0'
compile 'com.google.android.gms:play-services-places:10.2.0'
// Google Play Services Dependencies
compile 'com.google.android.gms:play-services-location:16.0.0'
compile 'com.google.android.gms:play-services-ads:17.1.1'
// All .jar files in ./libs
compile fileTree(dir: 'libs', include: ['*.jar'])
}
apply plugin: 'com.google.gms.google-services'
If your app has more than 65535 methods, you need to enable the multidex format for your app.
This can be caused by having lots of dependencies in your project.

Error in gradle file:More than one file was found with OS independent path 'META-INF/LICENSE'

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:transformResourcesWithMergeJavaResForDebug'.
> More than one file was found with OS independent path 'META-INF/mailcap.default'
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 {
}
}
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'
compile 'com.google.firebase:firebase-database:11.0.2'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.sun.mail:android-mail:1.6.1'
compile 'com.sun.mail:android-activation:1.6.1'
compile 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'
}
}
}
I have tried to implement the following solution which I found on the similar question:
On gradle:3.0.0 More than one file was found with OS independent path 'META-INF/ASL2.0'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
But it does not solve the problem.
Ps I have not much idea about gradle files

Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources,

I am developing small Android app
but I execute the code it showing something like this I didn't understand what is going on.Please help me
My gradle file like this
please help me to out of this problem
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.chinni.swipetabs"
minSdkVersion 8
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:design:23.1.0'
}
You are building a debug application. If you choose to building a release application, sources will be different(encrypt).

Error: duplicate files during packaging of APK after add Realm dependence to gradle

The problem is happening after I add the Realm Library to my project. I have this dependences in my gradle project:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'io.realm:realm-android:0.87.2'
}
I Found a lot of answers in the StackOverflow and I tested many of this but i have no success. Tryied this answer and this answer but i think my problem is something more specific.
I also added the suggestion of the LogCat error, but im getting the same error. Any answer will be appreciated.
I provide an image of the full error for a better look.
Move your android closure to be after the dependencies closure:
apply plugin: 'com.android.library'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'io.realm:realm-android:0.87.2'
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
The LogCat show this error Gradle DSL method not found: 'packagingOptions()'
Then you do not have packagingOptions inside android.
This is the packagingOptions { I use to typically be able to build anything so far.
android {
...
packagingOptions {
// Exclude file to avoid
// Error: Duplicate files during packaging of APK
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}

Could not resolve all dependencies for configuration ':app:_debugCompile' Houndify

I am trying to incorporate Houndify API into my project. However my gradle file would not build.
I downloaded a sample project from their site and it worked normally. I am migrating codes from that project gradle file to mine.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "edu.drexel.cs.ptn32.pennapps"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
signingConfigs {
debug {
storeFile file("debug.keystore")
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
repositories {
maven {
// The username and password for this repo is set below
url 'https://houndify.com/maven/'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile ('hound.android:hound-sdk:0.2.15#aar'){
transitive=true
}
compile ('hound.android:phrasespotter:1.4.0'){
transitive=true
}
}
setHoundifyMavenCredentials("user", "pw")
def setHoundifyMavenCredentials(username, password) {
for (repo in repositories) {
if (repo.properties.url.toString().equals("https://houndify.com/maven/")) {
repo.properties.credentials.username = username
repo.properties.credentials.password = password
}
}
}
Sorry to hear you are having problems migrating the Houndify SDK into your app. To make things easier, we've just removed the password restriction on the https://houndify.com/maven/ website. This means you can remove the setHoundifyMavenCredentials() portion from your build.gradle file. I suggest pulling the latest version of the Houndify sample app houndify-sdk-sample-0.2.17.zip and making sure it builds OK on your system, then all you should need to do is to add these lines to your build.gradle and it should pull in the Houndify libraries.
repositories {
maven {
url 'https://houndify.com/maven/'
}
}
dependencies {
compile ('hound.android:hound-sdk:0.2.15#aar'){
transitive=true
}
compile ('hound.android:phrasespotter:1.4.0'){
transitive=true
}
}
Finally make sure you Android build system is up-to-date.
Please let us know if you are still running into problems and thanks for your feedback. http://www.soundhound.com/contact

Categories

Resources