升级完Android Studio以后,默认使用classpath 'com.android.tools.build:gradle:3.0.0'。
新建Android项目后,再新建一个java library,如果java library使用了第三方jar包,运行时会报类找不到的异常。
如果把项目的gradle版本降级,换成classpath 'com.android.tools.build:gradle:2.3.3',则没有这个问题,java项目可以正常运行。
在GreenDao的集成文档(http://greenrobot.org/greendao/documentation/generator/)中,提到了这个问题的一个解决方法:
Note: If you have issues running the
main()method in Android Studio (NoClassDefFoundError, ClassNotFoundException or TemplateNotFoundException), try running the generator using the Gradle application plugin. Configure the class with yourmain()method in yourbuild.gradlefile:apply plugin: 'application' mainClassName = "com.example.YourGeneratorClass"Then execute the Gradle
runtask.
文档信息
- 本文作者:itlgl
- 本文链接:https://itlgl.com/note/2018/03/06/issues-2/
- 版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)