Compiler can not find AndroidInstrumentationTestCase2 when building Android app test code with Android makefile build system
I have a project with some Android test code in it (with the appropriate elements, <uses-library>
and <instrumentation>
, added to AndroidManifest.xml
). This works fine in Eclipse. However, it fails to build with mm
, claiming that it can't find the test-runner classes:
/home/orospakr/code/my-android/packages/apps/MyApp/src/ca/orospakr/myapp/test/functional/MyActivityTest.java:5: c开发者_如何学Cannot find symbol
symbol : class ActivityInstrumentationTestCase2
location: package android.test
import android.test.ActivityInstrumentationTestCase2;
^
I struggled with this problem for about a day before finding the fix. If you are using an Android.mk file to build your application, make sure to add this line:
LOCAL_SDK_VERSION := current
Other solutions I found suggested adding this line to the application section of the manifest, but it doesn't seem to make any difference for me:
<uses-library android:name="android.test.runner" />
精彩评论