本文介绍了Android的 - MultiDexEnable = true会导致毕加索崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的gradle这个文件中使用MultiDexEnable = true命令到cometChat SDK集成。但运行良好毕加索库崩溃现在给下面的错误。能否请您对解决方案指南?
应用插件:'com.android.application安卓{
compileSdkVersion 23
buildToolsVersion23.0.2
useLibraryorg.apache.http.legacy defaultConfig {
的applicationIDcom.edesign.astutesol.eyesapp
15的minSdkVersion
targetSdkVersion 23
版本code 1
的versionName1.0
multiDexEnabled真 }
/ * {库
行家{
URL'https://repo1.maven.org/maven2/
// URL'https://oss.sonatype.org/content/repositories/snapshots/
}
} * /
dexOptions {
javaMaxHeapSize4G
}
buildTypes {
发布 {
minifyEnabled假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
}
}
}依赖{
编译文件树(导演:'库',包括:['的* .jar'])
testCompile'的JUnit:JUnit的:4.12 /*compile('org.apache.httpcomponents:httpmime:4.3.6'){
排除模块:HttpClient的
}
编译org.apache.httpcomponents:HttpClient的-安卓4.3.5'* /
/ *编译com.loopj.android:android-async-http:1.4.9'*/
/ *编译com.loopj.android:android-async-http:1.4.9-SNAPSHOT'*/
编译com.android.support:appcompat-v7:23.1.1
编译com.nostra13.universalimageloader:通用图像装载机:1.9.3
编译com.mcxiaoke.volley:库:1.0.15
编译com.google.android.gms:播放服务,appindexing:8.1.0
编译com.google.android.gms:播放服务:8.4.0
编译com.google code.gson:GSON:2.2 +'
编译com.android.support:recyclerview-v7:23.1.1
编译com.android.support:cardview-v7:23.1.1
编译com.android.support:design:23.1.1
编译com.android.support:support-v13:23.1.1
编译com.squareup.picasso:毕加索:2.5.2
编译com.astuetz:pagerslidingtabstrip:1.0.1
编译de.hdodenhof:circleimageview:2.0.0
}
登录猫的
流程:com.edesign.astutesol.eyesapp,PID:29018 java.lang.NoClassDefFoundError的:com.squareup.picasso.Picasso $ 1
在com.squareup.picasso.Picasso< clinit>(Picasso.java:109)
在com.edesign.astutesol.eyesapp.BaseFragmentActivity.SetDrawer(BaseFragmentActivity.java:81)
在com.edesign.astutesol.eyesapp.BaseFragmentActivity.onCreate(BaseFragmentActivity.java:65)
在com.edesign.astutesol.eyesapp.MapsActivity.onCreate(MapsActivity.java:152)
在android.app.Activity.performCreate(Activity.java:5541)
在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2368)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2464)
在android.app.ActivityThread.access $ 900(ActivityThread.java:172)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1308)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:146)
在android.app.ActivityThread.main(ActivityThread.java:5653)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:515)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1291)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
在dalvik.system.NativeStart.main(本机方法)
解决方案
让你的应用程序类像波纹管
公共类MyAppClass扩展MultiDexApplication {
@覆盖
保护无效attachBaseContext(上下文newBase){
MultiDex.install(newBase);
super.attachBaseContext(newBase);
}
}
在你的依赖添加此库
{相关性
编译com.android.support:multidex:1.0.1
//你的依赖,你正在使用。}
I've used MultiDexEnable=true command in my gradle file to integrate the cometChat sdk . But Picasso library which was running fine is crashing now giving the following error. Can you please guide towards solution?
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 {
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('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'
}
Log Cat
Process: com.edesign.astutesol.eyesapp, PID: 29018 java.lang.NoClassDefFoundError: com.squareup.picasso.Picasso$1
at com.squareup.picasso.Picasso.<clinit>(Picasso.java:109)
at com.edesign.astutesol.eyesapp.BaseFragmentActivity.SetDrawer(BaseFragmentActivity.java:81)
at com.edesign.astutesol.eyesapp.BaseFragmentActivity.onCreate(BaseFragmentActivity.java:65)
at com.edesign.astutesol.eyesapp.MapsActivity.onCreate(MapsActivity.java:152)
at android.app.Activity.performCreate(Activity.java:5541)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2368)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2464)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5653)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
解决方案
make your application class like bellow
public class MyAppClass extends MultiDexApplication{
@Override
protected void attachBaseContext(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.
}
这篇关于Android的 - MultiDexEnable = true会导致毕加索崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!