我正在尝试调试我的应用。 当我点击“使用gradle文件同步项目”时,构建成功,但是当我尝试运行gradle控制台时,会出现“:app:compileDebugJava FAILED”。
这是我从gradle控制台构建的成功。
Executing tasks: [:app:generateDebugSources,:app:generateDebugAndroidTestSources]
Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportSupportV42103Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets 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:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE
BUILD SUCCESSFUL
Total time: 2.204 secs
和错误的gradle控制台如下:
Executing tasks: [:app:assembleDebug]
Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportSupportV42103Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets 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:compileDebugJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJava'.
> java.lang.NullPointerException
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or -- debug option to get more log output.
BUILD FAILED
Total time: 2.161 secs
Gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
lintOptions {
disable 'InvalidPackage'
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:21.+'
compile 'io.reactivex:rxjava:1.0.+'
compile 'io.reactivex:rxandroid:0.23.+'
compile 'com.squareup.retrofit:retrofit:1.8.+'
compile 'com.squareup.okio:okio:1.1.+'
compile 'com.andrewreitz:shillelagh:0.5.0'
provided 'com.andrewreitz:shillelagh-processor:0.5.0'
compile 'com.squareup.okhttp:okhttp:2.1.+'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.+'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.5@jar'
}
答案 0 :(得分:0)
我已经完成了这个问题,我使用的是JDK6,但项目是在JDK7上构建的,所以我安装了JDK7并设置了路径和java_home并再次运行,它运行正常....