Reputation: 2226
Sorry for adding just another "android maven google maps dependency not found" question, but I think that I have read most of the posts about it and applied all the proposed solutions with no success.
I have a maven Android project running OK with Google Maps V2 dependency that is not referenced using maven but via google-play-services_lib project imported in workspace and eclipse build path library dependency.
Now I am trying to configure the google-play-services dependency via pom, as I am implementing maven automated tests with Robolectric, but I am stuck with this error showing in first line of pom, with no quick-fix:
dependency=[com.google.android.gms:google-play-services:apklib:7:compile] not found in workspace
What I have tried so far, after lots of googling, and checking results after each step without success:
Initially installed google play services components to my local .m2 repository with android-maven-sdk-helper (following these instructions), and add to project pom two dependencies to jar and apklib version 7, which is my locally installed version (like here). After this it was supposed to work but the dependency error appeared.
Remove from eclipse build path the reference to library google-play-services_lib (in project / preferences / Android / Libraries). Anyway, google-play-services_lib project is still in the workspace.
Copy apklib from my local m2 repository into some place in workspace: I tried google-play-services_lib/bin, google-play-services_lib/libs, MyProject/libs. Tested using name google-play-services-7.apklib (as in repository file) and google-play-services.apklib.
"Mavenise" the google-play-services_lib project included in the workspace, by running eclipse Configure / Convert to Maven project. I edited the generated pom to update packaging type to apklib: <packaging>apklib</packaging>
, and added android-maven-plugin with <extensions>true</extensions>
in order to recognize the apklib package type. I compiled the project with maven goal compile, with success, but I can not find the generated apklib file anywhere.
After each of these changes I do Maven / Update project, clean project, even restart Eclipse. No success: the dependency not found in space error is still there.
I don't know what else to try. Could it be something with the library name? The library project name is google.play-services_lib, with _lib suffix, and the jar referenced in eclipse android library build path is the _lib.jar, but the maven artifacts do not have the _lib suffix. I have also tried some renaming in the components and artifacts with no success, but I guess the problem could be there. Could someone post an example pom.xml for the mavenised google-play-services_lib project?
Another guess: when I mvn compile the mavenised library project, why can't I find the generated .apklib file, where is it? I checked the trace with mvn -X compile and didn't find any hint.
Environment and versions:
Eclipse Indigo
External maven 3.0.5 (embedded Maven 3.0.3 not used)
android-maven-plugin 3.6.0
maven-eclipse-plugin 2.8
m2e-android plugin (m2eclipse android integration) 0.4.2
Android API level 13
The pom.xml I added to google-play-services_lib project:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>google-play-services_lib</groupId>
<artifactId>google-play-services_lib</artifactId>
<version>7</version>
<packaging>apklib</packaging>
<properties>
<android-platform>13</android-platform>
<android-emulator>13</android-emulator>
<android-maven-plugin-version>3.6.0</android-maven-plugin-version>
<maven-compiler-plugin-version>3.0</maven-compiler-plugin-version>
<java-version>1.6</java-version>
<local-sdk-path>C:\NoProgramFiles\Android\android-sdk</local-sdk-path>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android-maven-plugin-version}</version>
<configuration>
<sdk>
<path>${local-sdk-path}</path>
<platform>${android-platform}</platform>
</sdk>
<emulator>
<avd>${android-emulator}</avd>
</emulator>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin-version}</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 4
Views: 5007
Reputation: 13275
If problem persist with naming mismatch resolved (same name in library pom and project pom), after updating maven project (project explorer, right click any project->maven->update maven project) try just deleting that message (!!).
I problem tab, right-click error message and select 'Delete'. Worked for me and for Kevin Peck- Eclipse dependency not found in workspace fix
Upvotes: 1
Reputation: 2226
Finally the problem was about artifacts naming and apklib not being generated in the apk library project. This is what was wrong:
The right values:
<groupId>com.google.android.gms</groupId>
<artifactId>google-play-services</artifactId>
Instead of the ones generated by eclipse when converting the project to maven, which were based on the project name:
<groupId>google-play-services_lib</groupId>
<artifactId>google-play-services_lib</artifactId>
mvn compile
, the right instruction for that is mvn package
. This way the apklib file gets generated in target folder of the project library.So m2e-android 0.4.2 supports apklib dependency with mavenised google-play-services apklib, although the library project still has to be included in the workspace.
Final note: I got run time errors when running the maps activities in the real device:
07-08 09:42:45.170: W/dalvikvm(27953): VFY: unable to resolve virtual method 4296: Lcom/google/android/gms/maps/GoogleMap;.setMapType (I)V
07-08 09:42:45.180: E/dalvikvm(27953): Could not find class 'com.google.android.gms.maps.SupportMapFragment', referenced from method mypackage.MyMapActivity.setUpMapIfNeeded
07-08 09:42:45.180: W/dalvikvm(27953): VFY: unable to resolve check-cast 801 (Lcom/google/android/gms/maps/SupportMapFragment;) in Lmyapp/MyMapActivity;
07-08 09:42:45.180: E/dalvikvm(27953): Could not find class 'com.google.android.gms.maps.SupportMapFragment', referenced from method mypackage.MyMapActivity.onCreate
07-08 09:42:45.200: E/AndroidRuntime(27953): java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage/mypackage.MyMapActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
It seems that the maps library was not included in the app apk. My fix: in google-play_services_lib
project eclipse Properties / Java Build Path / Order and Export tab I checked the Android Private Libraries checkbox, so the original google maps jar is installed in the running device.
Upvotes: 1