處理AS報錯:compileDebugJavaWithJavac

在項目中,準備使用Realm作緩存。在gradle都配置好之后,寫了個demo進行測試,真的很簡單的demo。沒想到 Android studio 編譯時,報錯:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.

是的,錯誤信息只有這些,無從下手。
經(jīng)過一輪摸索,在工程目錄下,打開命令窗口,執(zhí)行 gradlew compileDebugJavaWithJavac , 得到文章最后面的編譯信息。
關(guān)注這一項:app:compileDebugJavaWithJavac,看到了導(dǎo)致錯誤的信息:

app:compileDebugJavaWithJavac
注: Processing class InventoryBarcodeBean
錯誤: A default public constructor with no argument must be declared if a custom constructor is declared.

是的,就是InventoryBarcodeBean.class 缺了空參構(gòu)造方法。然后為什么需要空參構(gòu)造呢,這里就不詳細說明了。

附:命令窗口執(zhí)行 gradlew compileDebugJavaWithJavac 打印出來的信息

To honour the JVM settings for this build a new JVM will be forked. Please consi
der using the daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:extractProguardFiles
:app:preReleaseBuild
:app:prepareComAndroidSupportAnimatedVectorDrawable2510Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72510Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2510Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42510Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2510Library UP-TO-DATE
:app:prepareComAndroidSupportTransition2510Library UP-TO-DATE
:app:prepareComFacebookStethoStetho141Library UP-TO-DATE
:app:prepareComGetkeepsafeRelinkerRelinker122Library UP-TO-DATE
:app:prepareComJiechicLibraryXUtils2614Library UP-TO-DATE
:app:prepareComTencentBuglyCrashreport265Library UP-TO-DATE
:app:prepareComUphycaStetho_realm200Library UP-TO-DATE
:app:prepareIoRealmRealmAndroidLibrary202Library UP-TO-DATE
:app:prepareOrgXutilsXutils3336Library UP-TO-DATE
:app:prepareWheelviewLibrary UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac
注: Processing class InventoryBarcodeBean
錯誤: A default public constructor with no argument must be declared if a custom
constructor is declared.
注: Creating DefaultRealmModule
警告: 將不對在最后一個循環(huán)中創(chuàng)建的類型為 'io.realm.DefaultRealmModule' 的文件進
行注釋處理。
警告: 將不對在最后一個循環(huán)中創(chuàng)建的類型為 'io.realm.DefaultRealmModuleMediator'
的文件進行注釋處理。
1 個錯誤
2 個警告
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.
    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.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 目錄 Getting StartedGetting HelpModelsRelationshipsWritesQu...
    Jafir閱讀 8,557評論 2 4
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,554評論 19 139
  • 1. 什么是協(xié)程 協(xié)程是協(xié)同程序(Coroutine)的簡稱(co前綴表示合作,routine即為程序)。具體來說...
    scvthedefect閱讀 374評論 0 0
  • 筑夢 逐夢 圓夢 ——我的教育觀 “做一名教師”是我兒時一直以來的夢,隨著成長經(jīng)過...
    一覽清歡閱讀 393評論 4 1

友情鏈接更多精彩內(nèi)容