欢迎光临
专注android技术,聚焦行业精粹,我们一直在努力

provided dependencies can only be jars

这个问题纠结了我很长时间,网上很多答案都不解决问题,直到今天才找到原因。

需要修改gradle build 插件的版本为1.0.0。虽然这样可行,但不建议这样做,因为gradle的版本太旧了,而且gradle限制provided的行为也有它的道理

原因:

我们看下插件1.1.0的更新记录

1.1.0 (2015/02/17)
Unit testing support. Unit testing code is run on the local JVM, against a special version of android.jar that is compatible with popular mocking frameworks (e.g. Mockito).
New tasks: test, testDebug/testRelease, testMyFlavorDebug (when using flavors).
New source folders recognized as unit tests:
src/test/java, src/testDebug/java, src/testMyFlavor/java etc.
New configurations for adding test-only dependencies, e.g.
testCompile ‘junit:junit:4.11’
testMyFlavorCompile ‘some:library:1.0’
Not compatible with Jack at the moment.
New option, android.testOptions.unitTests.returnDefaultValues to control the behaviour of the “mockable” android.jar.
Task names that used to contain ‘Test’, e.g. ‘assembleDebugTest’ now use ‘AndroidTest’, e.g. ‘assembleDebugAndroidTest’. This is to distinguish them from the unit test tasks, e.g. ‘assembleDebugUnitTest’.
ProGuard configuration files are no longer applied to the test APK. If minification is enabled, the test APK will be processed by ProGuard only to apply the mapping file generated when minifying the main APK.
Fixes and changes to the dependency management:
Properly handle ‘provided’ and ‘package’ scopes to do what they should be doing.
‘provided’ and ‘package’ cannot be used with Android Libraries, and will generate an error
sync tested and test dependency trees:
if the same version of an artifact is present in both, it’ll get skipped in the test app.
if the version is different it’ll generate a build error. Gradle provides mechanism to resolve this.
Added support for anyDpi resource qualifier in the resource merger.
Projects with large number of Android Modules will see evaluation and IDE sync speed improvements (YMMV)

android plugin 插件1.1.0开始不允许 provided android libraries,不然就会报错!因为provided对java类有效,而对资源文件是无效的,所以gradle在新版本修正了这个问题,保证provided只做它职责范围之内的事情!

 

 

赞(2) 打赏
未经允许不得转载:花花鞋 » provided dependencies can only be jars
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

国内精品Android技术社区

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏