2016-03-17 68 views
2

我有一个android应用程序,它支持android> = 4。 在调试编译时,它有> 65k的方法,因此它是multidex。 在发行版中,我使用了proguard,它有38k个方法,并且不是multidex。 我将如何开发一个应用程序,它在调试模式下可能会崩溃,只是因为它超过了65k方法?android proguard在调试版本?

我可以在调试版本中使用proguard,但没有看到任何人这样做+它需要更多时间编译,使用proguard 你将如何处理这种情况?

PS 我app.gradle看起来像这样(依赖的部分):

 compile project(':signalr-client-sdk-android') 
     compile fileTree(include: ['*.jar'], dir: 'libs') 

     compile 'com.android.support:recyclerview-v7:+' 
     compile "com.nostra13.universalimageloader:universal-image-loader:${UNIVERSAL_IMAGE_LOADER}" 
     compile "de.hdodenhof:circleimageview:${CIRCLE_IMAGE_VER}" 
     compile "com.pixplicity.multiviewpager:library:${MULTIVIEW_PAGER_VER}" 
     compile "com.michaelpardo:activeandroid:${ACTIVE_ANDROID_VER}" 
     compile "com.squareup.okhttp:okhttp:${OKHTTP_VER}" 
     compile "com.rockerhieu.emojicon:library:${EMOJI_VERSION}" 
     compile "com.facebook.android:facebook-android-sdk:${FACEBOOK_SDK_VER}" 
     compile "com.makeramen:roundedimageview:${ROUNDED_IMAGEVIEW_VER}" 
     compile 'com.github.orangegangsters:swipy:[email protected]' 

     compile "com.google.android.gms:play-services-gcm:${GSM_VER}" 
     compile "com.google.android.gms:play-services-analytics:${ANALITICS_VER}" 

     compile "com.flurry.android:analytics:${FLURRY_VER}" 

     compile 'com.supersonic.sdk:mediationsdk:[email protected]' 

     //effects apng tool 
     compile project(':android_api') 
     compile project(':flingCards') 

     compile files('libs/protobuf-java-2.6.1.jar') 

而且我用这一切的林达

+0

发布你的multidex代码,我认为你只能在gradle中使multidex成为true。 –

+0

我不想制作应用程序multidex!它会起作用,我的应用程序肯定应该保持不住multidex –

+0

如果你不想让应用程序作为multidex,然后删除一些对应用程序无用的jar文件并使用它。如果您使用播放服务,则在Gradle中使用特定播放服务依赖项。 –

回答

1

您可以在调试搭配使用ProGuard了。添加到您的buildTypes

debug { 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     minifyEnabled true 
     debuggable true 
     zipAlignEnabled true 
     jniDebuggable true 
    } 

内,您的应用程序build.gradle

+0

现在我正在这样做。但是,编译需要更多的时间,这是一个问题 –

+0

所以,我认为你只有几个选择,用Proguard减慢编译速度,不编译或尝试使用multidex,不需要很长时间。没有更多的选择。 –

+0

或者,也许你可以尝试通过改变它们来减少你的库。我看到你有一个“通用图像加载器”和“圆形图像视图”库,如果我没有错,你可以用Glide改变它们。 –

1

我用proguard的调试版本中。 Usualy我的build.gradle看起来是这样的:

buildTypes { 
    release { 
     minifyEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
    debug { 
     minifyEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro' 
    } 
} 

通知调试其中有添加-dontobfuscate选择不同的ProGuard文件(proguard-rules-debug.pro)。

用proguard编译它所花费的时间比我多了5-10%左右。我没有使用即时运行,所以我不知道它是如何受此影响的。

+0

伟大的解决方案。谢谢。 –