如何从javamail中获取.jar文件?
我正在使用intelliJ IDEA IDE并尝试去项目结构 - 库 - 添加 - 找到.jar文件并保存。然后我去模块并检查导出下的框,因为我也检查了用于片段等的支持库。
我使用了来自Sending Email in Android using JavaMail API without using the default/built-in app的代码,但没有运气。
我尝试完整地使用.jar文件以及提取后但都失败了同样的错误。
在代码的编辑模式下,我没有收到错误,只有在编译时,gradle构建失败并向我显示错误,“错误(3,6):Gradle:错误:包javax.mail不存在请帮帮忙!
我也尝试按照How can I use external JARs in an Android project?的说明操作,但我认为这些指示与eclipse IDE有关。
edt:gradle-build:
Information:Compilation completed with 25 errors and 0 warnings in 25 sec
Information:25 errors
Information:0 warnings
Error:Gradle: Execution failed for task ':app:compileDebugJava'.
编译失败;请参阅编译器错误输出以获取详细信 C:\用户\马库斯\文件\ IdeaProjects \的Android \ TestProjects \ TestMailFeature3 \应用\ SRC \主\的java \ COM \ majorwit \ testmailfeature3 \应用\ GMailSender.java
Error:(3, 24) Gradle: error: package javax.activation does not exist
Error:(4, 24) Gradle: error: package javax.activation does not exist
Error:(5, 18) Gradle: error: package javax.mail does not exist
Error:(6, 18) Gradle: error: package javax.mail does not exist
Error:(7, 18) Gradle: error: package javax.mail does not exist
Error:(8, 18) Gradle: error: package javax.mail does not exist
Error:(9, 27) Gradle: error: package javax.mail.internet does not exist
Error:(10, 27) Gradle: error: package javax.mail.internet does not exist
Error:(18, 44) Gradle: error: package javax.mail does not exist
Error:(22, 13) Gradle: error: cannot find symbol class Session
Error:(46, 15) Gradle: error: cannot find symbol class PasswordAuthentication
Error:(67, 49) Gradle: error: cannot find symbol class DataSource
Error:(43, 19) Gradle: error: cannot find symbol variable Session
Error:(47, 20) Gradle: error: cannot find symbol class PasswordAuthentication
Error:(52, 13) Gradle: error: cannot find symbol class MimeMessage
Error:(52, 39) Gradle: error: cannot find symbol class MimeMessage
Error:(53, 13) Gradle: error: cannot find symbol class DataHandler
Error:(53, 39) Gradle: error: cannot find symbol class DataHandler
Error:(54, 35) Gradle: error: cannot find symbol class InternetAddress
Error:(58, 46) Gradle: error: package Message does not exist
Error:(58, 65) Gradle: error: cannot find symbol variable InternetAddress
Error:(60, 45) Gradle: error: package Message does not exist
Error:(60, 68) Gradle: error: cannot find symbol class InternetAddress
Error:(61, 13) Gradle: error: cannot find symbol variable Transport
答案 0 :(得分:2)
The javax.activation and javax.mail packages are not part of the standard android packages (http://developer.android.com/reference/packages.html).
Fortunately an Android version has of JavaMail been released (https://java.net/projects/javamail/pages/Android). I followed the suggestion of modifying the build.gradle file for my project in Android Studio and was able to successfully compile without having to manually download any jar files.
<?php
//assign your value
$value = true;
?>
<input id="value" type="hidden" value="<?php if ($value) { echo 'true'; } ?>" />
<script>
var value = document.getElementById('value').value;
if (value) {
alert(value);
}
</script>
答案 1 :(得分:0)
我将以下内容添加到我的build.gradle(Module:app)文件中,并且编译时没有错误。
dependencies {
//other dependencies here...
compile 'com.sun.mail:android-mail:1.5.5'
compile 'com.sun.mail:android-activation:1.5.5'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
一个区别在于我的情况是一个Android项目。