Diana
Diana

Reputation: 2226

dependency=[com.google.android.gms:google-play-services:apklib:7:compile] not found in workspace

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:

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

Answers (2)

Bartosz Bilicki
Bartosz Bilicki

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

Diana
Diana

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 groupId and artifactId in the library pom were wrong: they must fit the name specified in the error message (I should have read it more carefully).

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>
  • The apklib is not generated with 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

Related Questions