java.lang.NullPointerException(没有错误信息)

新手上路,请多包涵

我知道我的这个问题已经被问过很多次了,我确实遵循了大多数答案,但没有一个对我有帮助。所以这是我的问题,每当我同步我的项目时,它总是失败。下面是 gradle 控制台的样子:

执行任务:[:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]

按需配置是一项孵化功能。增量java编译是一个孵化特性。 :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2420Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72420Library UP-TO-DATE : app:prepareComAndroidSupportDesign2420Library UP-TO-DATE :app:prepareComAndroidSupportMediarouterV72300Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72420Library UP-TO-DATE :app:prepareComAndroidSupportSupportCompat2420Library UP-TO-DATE :app:prepareComAndroidSupportSupportCoreUi2420Library UP-TO-DATE :app:prepareComAndroidSupportSupportCoreUtils2420Library UP-最新:app:prepareComAndroidSupportSupportFragment2420图书馆最新:app:prepareComAndroidSupportSupportMediaCompat2420图书馆最新:app:prepareComAndroidSupportSupportV42420图书馆最新:app:prepareComAndroidSupportSupportVectorDrawable2420图书馆最新:app:40准备ComGoogleAndroidGmsLibrary :准备ComGoogleAndroidG msPlayServicesAds940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAdsLite940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAnalytics940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppindexing940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppinvite940Library UP-TO- DATE :app:prepareComGoogleAndroidGmsPlayServicesAuth940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAuthBase940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBase940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBasement940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesCast940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesCastFramework940Library最新:app:prepareComGoogleAndroidGmsPlayServicesClearcut940图书馆最新:app:prepareComGoogleAndroidGmsPlayServicesContextmanager940图书馆最新:app :prepareComGoogleAndroidGmsPlayServicesDrive940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesFitness940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesGames940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesGass940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesGcm940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesIdentity940Library FAILURE: Build异常失败。

  • 出了什么问题:java.lang.NullPointerException(没有错误信息)

  • 尝试:使用 –stacktrace 选项运行以获取堆栈跟踪。使用 –info 或 –debug 选项运行以获得更多日志输出。

构建失败

总时间:7.518 秒

这些是我的依赖

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.google.android.gms:play-services:9.4.0'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-location:9.4.0'
    compile 'com.google.android.gms:play-services-appindexing:9.4.0'
    compile 'com.google.firebase:firebase-messaging:9.2.0'
    compile 'com.google.firebase:firebase-database:9.0.2'
    compile 'com.firebase:firebase-client-android:2.4.0'
    compile 'com.google.firebase:firebase-core:9.4.0'
}

apply plugin: 'com.google.gms.google-services'

如何解决问题?

原文由 sweetzyl pili 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 700
2 个回答

我已经从项目中删除 了 .gradle 文件夹,并且能够再次重建它。

注意:做一个备份,以防万一。

原文由 rastik 发布,翻译遵循 CC BY-SA 4.0 许可协议

我也有同样的错误。我通过以下方式解决了它: 使缓存无效并重新启动 Android Studio

原文由 Ali Zahid 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题