8

I want to make in Android Studio my test module to be dependent of application module, but can not achieve this, have mistake

Error:Dependency AndroidApp:app:unspecified on project TestsRobotium resolves to an APK archive which is not supported as a compilation dependency. File: D:\android\MEWE\AndroidApp\app\build\apk\MeWe.apk

In my test.gradle I added provided project(':app') in dependency tag (it is done by Android studio automatically)

How would I resolve this? I need dependency on src, res folders of my main app and need to know R file

Anton Kizema
  • 1,072
  • 3
  • 13
  • 27
  • 2
    Take a look [link](http://stackoverflow.com/questions/27536491/how-to-import-android-project-as-library-and-not-compile-it-as-apk-android-stud?answertab=votes#tab-top) and [link](http://stackoverflow.com/questions/27364565/how-to-import-material-design-library-to-android-studio?answertab=votes#tab-top) – Skizo-ozᴉʞS ツ Jan 27 '15 at 08:13
  • Feels like good decithion in a link provided. But I need application to be a project(module), not library, and need to have dependency on it (so I can rely on src, res and r.java of application from tests). Maybe there is some way achieving this? – Anton Kizema Jan 27 '15 at 08:23
  • @AntonKizema were you able to figure it out? – amadib Mar 03 '15 at 03:58
  • 2
    @amadib nope, I simply moved test code into app module. – Anton Kizema Mar 03 '15 at 15:39

1 Answers1

1

This is now possible using com.android.test plugin. Works fine for Java and resources stuff.

An example by Google can be found here.

Basically you create a separate module for testing and define which module and flavor should be tested. I've just checked it and it has some issues with working with the IDE, but runs fine with gradle command line.

Marcin Kunert
  • 5,596
  • 5
  • 26
  • 52