在項目中,準備使用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.