Android Studio 1.3.2 NDK编译报错 'com.android.build.gradle.managed.ProductFlavor_Impl'

Android Studio 1.3.2已经支持NDK的编译,调试。但是已经跟老的项目通过配置 Application.mk,Android.mk来编译NDK的形式完全不同了。参考编译配置文档,采用了Gradle 2.5的配置方式(详细配置参考 Android Studio 1.3 配置编译NDK参考文档,Google官方链接),结果在编译报错,显示如下信息:

Error:Unable to load class 'com.android.build.gradle.managed.ProductFlavor_Impl'.
Possible causes for this unexpected error include:

  • You are using JDK version 'java version "1.7.0_80"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle.
    Please update to a newer version (e.g. 1.7.0_67).
    Open JDK Settings
  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
    Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
    Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

查找了好长时间原因,最后发现,是由于build.gradle中修改有问题。
先看看有问题的build.gradle,注意defaultConfig.with部分的差别

修改后的为(注意defaultConfig.with部分的差别

一个疏忽,浪费时间很多啊!

发布者

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注