问题
My development environment:
- adt:22.3.0
- android-maven-plugin:3.8.2
- maven:3.1.1
I am developing a google map Android app with maven structure and dependencies as below:
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>google-play-services</artifactId>
<version>13.0.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>google-play-services</artifactId>
<version>13.0.0</version>
</dependency>
or
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services</artifactId>
<version>4.0.30</version>
<type>aar</type>
</dependency>
I tried apk and aar type but I still can't use resource drawable, string etc (R.drawable.poi, R.style.button_style1..) in android lib dependency. How can I handle this?
回答1:
To use the resource drawables of Library, you also have to import the project into eclipse workspace and reference it from your mavenized project.
I faced this problem, solved it by importing Google-play-services project to workspace and referencing it from my maven project.
For referencing. right click on your project->Properties->Android->(libraryProjects->Add->[browse google-play-library project]), click on apply and save it.
you can find google-play-library project in sdk/extras/google/
回答2:
A similar problem appeared in our project after updating android-maven-plugin
from version 3.8.0 to 3.8.2
, android-maven-plugin looks bugy.
We had to fallback to version 3.8.0
. I recommend you to do the same using apklib as aar is only available since version 3.8.2 and in case you want to use aar
to wait for later version of android-maven-plugin.
In details, the problem was in the linking of the apklib, all ressources (layouts, drawables...) referenced seemed to be disaligned. For example a layout or a drawable was displayed instead of another. Application was crashing when accessing to a missing reference/id in a layout (the reference was not present because the wrong layout was loaded).
See issue http://code.google.com/p/maven-android-plugin/issues/detail?id=441
来源:https://stackoverflow.com/questions/21136494/how-to-use-resource-in-android-library-dependency-on-adt