0

I am trying to setup espresso in a project.
I created a new empty activity project in Android Studio (1.5.1)
It has no problems running

added the espresso configurations to the project and a test class.
When running the test I am getting

  android.content.res.Resources$NotFoundException: Resource ID #0x7f030015
  at android.content.res.Resources.getValue(Resources.java:1266)
  at android.content.res.Resources.loadXmlResourceParser(Resources.java:2649)
  at android.content.res.Resources.getLayout(Resources.java:1082)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:412)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
  at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:358)
  at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:279)
  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:253)
  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
  at com.adi.MainActivity.onCreate(MainActivity.java:11)
  at android.app.Activity.performCreate(Activity.java:5990)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
  at android.support.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:494)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
  at android.app.ActivityThread.access$800(ActivityThread.java:151)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:135)
  at android.app.ActivityThread.main(ActivityThread.java:5254)
  at java.lang.reflect.Method.invoke(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

BTW the ID is for the toolbar

The test class is

@RunWith(AndroidJUnit4.class)
public class MainActivityTest {

   @Rule
   public ActivityTestRule<MainActivity> mActivityRule =
        new ActivityTestRule<>(MainActivity.class);

   @Test
   public void test(){}
}

gradle.build is

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.adi"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'

    androidTestCompile 'com.android.support.test:runner:0.3'
    androidTestCompile 'com.android.support.test:rules:0.3'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
    androidTestCompile 'com.android.support:appcompat-v7:23.1.1'
}

What am I doing wrong?

piotrek1543
  • 19,130
  • 7
  • 81
  • 94
Guy
  • 377
  • 1
  • 4
  • 10

1 Answers1

0

I've already found on StackOverflow site similar problem. Take a look at this Chris Banes explanation and solution:

AppCompat is now more strict on what it expect in theme window flags, more closely matching what you would get from the framework.

The main reason behind this is to support AppCompatDialogs which we were also adding in this release. They make heavy use of the windowNoTitle flag, which AppCompat previously didn't pay much attention to.

So to fix your issue you have two options:

The easy way is to just use Theme.AppCompat.NoActionBar as your parent theme. This will always do the right thing.

If you can't do that though (maybe you need to support action bar and no action bar), you should do the following:

<style name="MyTheme" parent="Theme.AppCompat">
    ...
</style>

<style name="MyTheme.NoActionBar">
    <!-- Both of these are needed -->
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

You should be back on track now.

From: Upgraded to AppCompat v22.1.0 and now getting IllegalArgumentException: AppCompat does not support the current theme features

As you would notice, you don't need to delete from your build.gradle file support.v7... dependencies. Just make some changes in your Activity theme.

EDIT: Change also buildToolsVersion "22.0.1" to 23.0.2 version.

Hope it help

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94
  • thanks for the response, tried all suggestions but still doesn't work... in any case I need the action bar. – Guy Jan 17 '16 at 08:23