Exception in thread “main” java.lang.NoClassDefFoundError: junit/textui/ResultPrinter

前端 未结 8 1212
长发绾君心
长发绾君心 2020-12-03 06:35

I\'m trying to compile my Android project in Android Studio 0.3.0. Today I get the following error:

Exception in thread \"main\" java.lang.NoClassDefFoundErr         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 06:51

    All the answers are good-

    Make sure you have sourceSets have the test directory registered.

    android{
        ...
    
        defaultConfig {
             ...
             testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
    
    
        sourceSets {
            androidTest {
                java.srcDirs = ['src/androidTest/java']
            }
        }
    }
    
    dependencies{
        ... 
        androidTestCompile 'junit:junit:4.12'
        androidTestCompile 'com.android.support.test:runner:0.5'
    }
    

提交回复
热议问题