Trying to add MultiDex support - cannot find symbol context and MultiDex

后端 未结 4 1934
不思量自难忘°
不思量自难忘° 2021-02-19 22:39

After following the instructions mentioned at: https://developer.android.com/studio/build/multidex.html#mdex-gradle

I am getting an error cannot find symbol

相关标签:
4条回答
  • 2021-02-19 22:50

    The reason you are having this "symbol not found" issue is because you haven't imported the required imports. Why not simply add the following imports

    import android.support.multidex.MultiDex;

    import android.content.Context;

    You should know the different cases for using each Multidex option. Kindly refer to https://developer.android.com/studio/build/multidex#java for all information relating to MultiDexing

    0 讨论(0)
  • 2021-02-19 23:11

    Thanks to @Gabe Sechan for the help. I know React Native/JavaScript, kind of clueless about Android/Java, so I simply followed the instructions at https://developer.android.com/studio/build/multidex.html#mdex-gradle, which did not mention any additional imports. I learned to look up the package I needed here: https://developer.android.com/reference/android/support/multidex/MultiDexApplication.html. After adding:

    import android.support.multidex.MultiDexApplication;
    
    public class MainApplication extends MultiDexApplication implements ReactApplication {
    ...
    

    App seems to build and run successfully on Android 4.4.4+ devices. On my Samsung Galaxy S3 simulator running 4.3 however, I am getting a crash upon app start: What does WIN DEATH: android.osDeadObjectException mean?, which seems like another issue altogether.

    0 讨论(0)
  • 2021-02-19 23:12

    For those who get cannot find symbol error, the following is stated in the official android developer documents:

    If your minSdkVersion is 21 or higher multidex is enabled by default, and you do not need the multidex support library.
    
    0 讨论(0)
  • 2021-02-19 23:14

    If you are using RN > 0.60 and androidx support, you may add,

    import androidx.multidex.MultiDex;
    
    0 讨论(0)
提交回复
热议问题