Я создал пустой проект Android в IntelliJ IDEA и добавил следующую строку в app/build.gradle
:
dependencies {
...
compile 'javax.mail:javax.mail-api:1.6.2'
...
}
Теперь я могу import javax.mail.internet.MimeBodyPart;
и другие классы из javax.mail
:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new MimeBodyPart();
}
Приложение успешно собирается.Тем не менее, если я запустил его, я получу FATAL EXCEPTION
:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sun/mail/util/PropUtil;
at javax.mail.internet.MimeBodyPart.<clinit>(MimeBodyPart.java:91)
at com.example.myapplication.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sun.mail.util.PropUtil" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/base.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.myapplication-gtunpTdStbiuDO78f_fC_g==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at javax.mail.internet.MimeBodyPart.<clinit>(MimeBodyPart.java:91)
at com.example.myapplication.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)