开发者

Using custom attributes with Android Instrumentation Tests

i have an android project containing two sub-projects (the app and the instrumentation tests). Everything built fine with maven-android-plugin until i added some custom attributes (res/values/attrs.xml) to my app. To use the custom attributes i had to define a new namespace in my referencing xml file (res/xml/someFile.xml): <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fosslab="http://schemas.android.com/apk/res/org.fosslab.android.hazard"> The app itsself is building fine, but the instrumentation test project has another package name declared in AndroidManifest.xml and thats why the instrumentation test project cannot be build.

The error is: hazard-it/res/xml/settings_filter.xml:4: error: No resource identifier found for attribute 'stepSize' in package 'org.fosslab.android.hazard'

Before building the instrumentation pr开发者_Go百科oject all files from res/* (from the app project) get copied to the instrumentation project.

The error seems clear, because for the instrumentation test the namespace declaration should be org.fosslab.android.hazard.tests.

Has anyone an idea how to automate such changes for instrumentation testing. Or could i leave the namespace and should change something else in my instrumentation test project?

Edit: Solved the problem by deleting the whole res folder from instrumentation project and stopped copying resources from app to instrumentation. Marked app apklib and app jar as provides in pom.xml and eveything seems working.


Your solution does allow to compile the project, but it does not include it into the dex file.

I was able to solve this problem by using a name space like this one:

xmlns:something="http://schemas.android.com/apk/lib/the.package.name"

Notice the /lib/ instead of /res/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜