美文网首页
[Android开发中方法数超过65535的简单解决方法

[Android开发中方法数超过65535的简单解决方法

作者: 槐树向北 | 来源:发表于2017-09-06 09:06 被阅读20次
<activity android:name=".iehpapi.IEHPAccountActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar">
           <intent-filter>
                <action android:name="IEHPAccount"/>
           </intent-filter
 </activity>

(转)Android开发中方法数超过65535的简单解决方法](http://www.cnblogs.com/yinkaiblog/p/6888277.html)
有时候我们的项目会依赖很多第三方的Module,当方法数超过了65535的时候会在打包成apk的时候失败。
对于这种情况,Google官方提供了一个补丁包,将我们的项目进行分包处理。
第一步:
  修改项目中所有需要打包的Module的build.gradle。
1、添加 multiDexEnabled = true。如:

defaultConfig {    
  applicationId "com.biketo.rabbit"   
  minSdkVersion 15   
  targetSdkVersion 22   
  versionCode 956   
  versionName "0.9.5.6"   
  **multiDexEnabled = true**  
} 

2、在android节点下添加:

dexOptions {    
javaMaxHeapSize "2g"   
jumboMode = true  
}

第二步:  
在主Module的build.gradle中添加依赖包:

compile 'com.android.support:multidex:1.0.0'

第三步:  让我们的Application继承自 MultiDexApplication
第四步:  rebuild 工程。OK,这下就不会报错了。

相关文章

网友评论

      本文标题:[Android开发中方法数超过65535的简单解决方法

      本文链接:https://www.haomeiwen.com/subject/qpdmjxtx.html