have a problem with gradle, my app wont compile and appear this error on "0:Messages" tab, here my code on my build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "app.nucleo.com.doctoc"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(path: ':backend', configuration: 'android-endpoints')
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
compile 'com.android.support:support-v4:24.0.0-alpha2'
compile 'com.android.support:design:24.0.0-alpha2'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.28'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
screenshot:
http://i.stack.imgur.com/6BTaw.png
any can help me?
remove from your dependencies:
compile 'com.google.android.gms:play-services:8.4.0'
and look exactly for what else you need from play-services from here.
Fine tune your play-services so you don't include the entire package. Then it won't exceed the 64k function limit and you can remove the multidex thing that I assume you added because it was objecting.
multiDexEnabled false
And the exact play services so it all fits in the same same dex file.
Related
I was adding Appbrain Sdk for Ads to my app gradle
compile 'com.appbrain:appbrain-sdk:14.30'
Now I'm getting this error:
Error:The number of method references in a .dex file cannot exceed 64K.
I followed the instruction by adding multiDexEnabled true to my code and I get OutOfMemoryException
Here is my code
my app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.webstore.footballscores"
minSdkVersion 17
targetSdkVersion 26
versionCode 8
versionName "1.7"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.google.android.gms:play-services-ads:15.0.1'
compile 'com.facebook.android:audience-network-sdk:4.23.0'
compile 'com.google.firebase:firebase-core:16.0.0'
compile 'com.google.firebase:firebase-iid:16.0.0'
compile 'com.google.firebase:firebase-messaging:17.0.0'
compile 'com.google.android.gms:play-services-analytics:16.0.0'
compile 'com.google.android.gms:play-services-tagmanager:16.0.0'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.8.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.startapp:inapp-sdk:3.9.3'
compile 'com.appbrain:appbrain-sdk:14.30'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck=true
Add this code block to your build.gradle in android block.
dexOptions {
javaMaxHeapSize "4g"
}
instead of
dexOptions {
jumboMode true
}
This should solve your problem. Good luck.
I have attached all the gradle dependencies of my app (which I think are the reason the app slows down).
Kindly tell me if any of the dependencies can be replaced with more specific ones or if they can be avoided all together.
Also I know that my app does slow down a bit due to enabling multi dex support but I had to enable it as my app was crashing when I had it disabled.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.neeraj8le.srmfoodies"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
No need to replace or edit any gradle build link, It taking load when User first time app is installed. This is happening in all type of Applications like Whatsapp, Linkedin, etc.
I am developing a project, which uses a module(library project). Independently both are working fine, but when I am integrating both they starts to throw error in gradle build.
**Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.commom.process.ProcessException: org.gradle.process.internal.ExceException: Process 'command'C:\Program Files\Java\jdk1.8.0_65\bin\java.exe" finished with non-zero exit value 2**
I have almost same import of library set in both the modules, because of security issues I needed to put these modules seperately.
Following are the build.gradle files for both
app : build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "*************************"
multiDexEnabled true
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/khandroid-httpclient-4.2.3.jar')
compile project(':library')
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup:otto:1.3.5'
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'commons-codec:commons-codec:1.6'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
library : build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
multiDexEnabled true
minSdkVersion 14
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'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.squareup:otto:1.3.5'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'commons-codec:commons-codec:1.6'
}
I had already enabled multidexedenabled true .
Any help will be appreciable. Thanks
I solved this issue.Following are the steps I take:
1) In gradle.properties file of project un-comment the line
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
And write : org.gradle.daemon=true
2)In my project module app:build.gradle, I removed all the dependencies that has been there in library's build.gradle file.
that is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.mabna.hearthurt"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
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.github.traex.rippleeffect:library:+'
// compile 'com.balysv:material-ripple:1.0.2'
compile 'com.squareup.picasso:picasso:2.5.0'
}
but this error occured:
error(32,13) failed to resolve: com.squareup.picasso:picasso:2.5.1
also for:
compile 'com.github.traex.rippleeffect:library:+'
compile 'com.balysv:material-ripple:1.0.2'
and other external dependencies error occured.
i have sample of com.github.traex.rippleeffect:library:+ and com.squareup.picasso:picasso:2.5.1 and other dependencies compiled with no error.
so what is the problem
At First Remove + calling from Gradle
Do
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.android.support:appcompat-v7:23.1.0' // Instead yours
Edit
Call multiDexEnabled true
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
Then Clean-Rebuild-Sync in your Project.
Dependencies is a virtual folder where IDE shows what JAR files the
project depends on.
#Solivan I guess it's packaging bug . Whenever you create a new project then this bugs omitted .
Even after adding the dependencies and importing the class I am getting java.lang.NoClassDefFoundError: com.squareup.okhttp.logging.HttpLoggingInterceptor.
Can anyone please help?
Gradle Build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "xyz"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
mavenCentral()
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
}
In my case, I found that the versions of the okhttp3 and okhttp3:logging-interceptor dependencies needed to exactly match. So for example:
...
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
...
Could be a compatibility problem with retrofit.
Try with :
implementation 'com.squareup.okhttp:logging-interceptor:2.5.0'
This post could be help
App crash on HttpLoggingInterceptor
Also it can be connected with multidex true option in your build.gradle (yes, seems like some devices have problems with multidex apps (read, Samsung))
If this is your case, switch this flag off and rebuild your project. Consider using
minifyEnabled true
shrinkResources true
to reduce your apk size. If it is still too large, that's really weird and bad news, but there are some techniques to put your apk on diet.