Android - Multidexenable=true Causes Picasso To Crash
Solution 1:
make your application class like bellow
publicclassMyAppClassextendsMultiDexApplication{
@OverrideprotectedvoidattachBaseContext(Context newBase) {
MultiDex.install(newBase);
super.attachBaseContext(newBase);
}
}
add this library in your dependencies
dependencies {
compile 'com.android.support:multidex:1.0.1'// your dependencies which you are using.
}
Solution 2:
You need to handle Multiple dex file after enabling that option from build.gradle
& if in your project are you using Application class than extend it by with MultiDexApplication
& handle multiple dex file in attachBaseContext
To install MultiDex.install i refer android developer link
Eg.
publicclassMyAppClassextendsMultiDexApplication{
@OverrideprotectedvoidattachBaseContext(Context newBase) {
MultiDex.install(newBase);
super.attachBaseContext(newBase);
}
}
Declare MyAppClass
in your AndroidManfiest file application name.
<application
android:name="MyAppClass"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
//... your other manifest declaration
</application>
Updated gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.edesign.astutesol.eyesapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
/*repositories {
maven {
url 'https://repo1.maven.org/maven2/'
// url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}*/
dexOptions {
jumboMode = true
incremental true
// here heap size give 4g i got this thing from https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY
javaMaxHeapSize "4g"
}
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:multidex:1.0.1'
//your dependencies which you are using.
/*compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile'org.apache.httpcomponents:httpclient-android:4.3.5'*/
/*compile'com.loopj.android:android-async-http:1.4.9'*/
/*compile'com.loopj.android:android-async-http:1.4.9-SNAPSHOT'*/
compile'com.android.support:appcompat-v7:23.1.1'compile'com.nostra13.universalimageloader:universal-image-loader:1.9.3'compile'com.mcxiaoke.volley:library:1.0.15'compile'com.google.android.gms:play-services-appindexing:8.1.0'compile'com.google.android.gms:play-services:8.4.0'compile'com.google.code.gson:gson:2.2.+'compile'com.android.support:recyclerview-v7:23.1.1'compile'com.android.support:cardview-v7:23.1.1'compile'com.android.support:design:23.1.1'compile'com.android.support:support-v13:23.1.1'compile'com.squareup.picasso:picasso:2.5.2'compile'com.astuetz:pagerslidingtabstrip:1.0.1'compile'de.hdodenhof:circleimageview:2.0.0'
}
Suggestion
Use only required play service library do not add entire Group of play service . Refer this link. it will reduce the number of method count & unused library too.
Example
compile'com.google.android.gms:play-services:8.4.0'
with these lines(add artifactId (group) according to the required feature like play-services-fitness
play-services-wearable
etc):
compile'com.google.android.gms:play-services-fitness:8.4.0'compile'com.google.android.gms:play-services-wearable:8.4.0'
with reference of my answer for other questions
Post a Comment for "Android - Multidexenable=true Causes Picasso To Crash"