gpt4 book ai didi

android - java.lang.NoClassDefFoundError : Failed resolution of: Lcom/sun/mail/util/PropUtil; when trying to use javax. 邮件

转载 作者:行者123 更新时间:2023-11-30 05:10:51 34 4
gpt4 key购买 nike

我在 IntelliJ IDEA 中创建了一个空的 Android 项目,并将以下行添加到 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) 

最佳答案

javax.mail:javax.mail-api:1.6.2 是 Java SE 的实现,不适用于 Android。尝试使用另一个库:

compile 'com.sun.mail:android-mail:1.6.2'

关于android - java.lang.NoClassDefFoundError : Failed resolution of: Lcom/sun/mail/util/PropUtil; when trying to use javax. 邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53784104/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com