如果导入的jar包大于65535怎么解决

作者: 穿越平行宇宙 | 来源:发表于2019-07-25 20:37 被阅读0次

    报错:

    Cannot fit requested classes in a single dex file. Try supplying a main-dex list.
    # methods: 71698 > 65536
    Message{kind=ERROR, text=Cannot fit requested classes in a single dex file. Try supplying a main-dex list.
    # methods: 71698 > 65536, sources=[Unknown source file], tool name=Optional.of(D8)}
    

    解决:

    1. 导入依赖
        implementation 'com.android.support:multidex:1.0.3'
    
    1. 在Model下的build.gradle 中添加一行代码
     defaultConfig {
            ...
            multiDexEnabled true
        }
    
    1. 在Activity中添加一行代码
      protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_map);
    
            MultiDex.install(this);
    }
    

    相关文章

      网友评论

        本文标题:如果导入的jar包大于65535怎么解决

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