當我添加@NotNull或@Nullable註釋參數的Android Studio會自動幫助我增加/lib/annotations.jar和進口進口NOTNULL或可空和Android Studio將無法編譯
import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.Nullable;
但經過這個項目不會編譯。如果我也刪除註釋,但保留導入語句,項目仍然不會編譯。 但是如果我刪除了NotNull和Nullable的導入語句,項目編譯罰款!
Android Studio中給出了一個通用的錯誤:
Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Bugtester:compileDebug'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
運行gradlew compileDebug
從CMD給人一種輕微的暗示:
:Bugtester:compileDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Bugtester:compileDebug'.
> Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
所以,我檢查了我的環境變量和它們設置爲:
JAVA_HOME=C:\Program Files (x86)\Java\jre7
JDK_HOME=C:\Program Files\Java\jdk1.7.0_21\
任何人都有這個想法嗎? (我是java和android編程的新手)
我不熟悉gradle這個,但你應該添加依賴在'annotations.jar'到'build.gradle'上。像'依賴關係{編譯文件('full/path/to/annotations.jar')}' –
謝謝,這解決了這個問題!我認爲添加依賴項是android studio在第一次寫入@NotNull時自動執行的操作,它希望我添加一些東西。 – Moberg
你可以在這裏找到這個行爲的解釋http:// stackoverflow。com/questions/16622410/how-do-i-add-a-library-project-to-the-android-studio-and-use-itsome-asked-dont/16683375#16683375 –