我使用Android Maven插件1.01在Spring Framework STS 3.5.1中安装了Google Map项目。
一切都很好 - 我的IDE中没有显示错误。 我已将googleplay_services_lib设置为andoid的Libary项目。 R文件生成正确。 缺少的属性位于com.googgle.android.gms R.Java文件中。
但是当涉及到生成源maven在执行aapt
时失败[DEBUG] D:\Programme\androis-sdks\build-tools\17.0.0\aapt.exe [package, -m, -J, D:\workspace-sts-3.5.0.RELEASE\MyAndroid\target\generated-sources\r, -f, --no-crunch, -M, D:\workspace-sts-3.5.0.RELEASE\MyAndroid\AndroidManifest.xml, -S, D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res, --auto-add-overlay, -A, D:\workspace-sts-3.5.0.RELEASE\MyAndroid\target\generated-sources\combined-assets, -I, D:\Programme\androis-sdks\platforms\android-19\android.jar, --output-text-symbols, D:\workspace-sts-3.5.0.RELEASE\MyAndroid\target]
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:29: error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:29: error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:29: error: No resource identifier found for attribute 'cameraZoom' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:38: error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:38: error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:38: error: No resource identifier found for attribute 'cameraZoom' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:54: error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:54: error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:54: error: No resource identifier found for attribute 'cameraZoom' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:63: error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:63: error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:63: error: No resource identifier found for attribute 'cameraZoom' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'cameraBearing' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'cameraTilt' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'cameraZoom' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'mapType' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'uiCompass' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'uiRotateGestures' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'uiScrollGestures' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'uiTiltGestures' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'uiZoomControls' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\options_demo.xml:17: error: No resource identifier found for attribute 'uiZoomGestures' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\split_street_view_panorama_and_map_demo.xml:36: error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\split_street_view_panorama_and_map_demo.xml:36: error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.pekam.myandroid'
[INFO] D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\split_street_view_panorama_and_map_demo.xml:36: error: No resource identifier found for attribute 'cameraZoom' in package 'com.pekam.myandroid'
[DEBUG] ANDROID-040-000: Executed command: Commandline = cmd.exe /X /C "D:\Programme\androis-sdks\build-tools\17.0.0\aapt.exe package -m -J D:\workspace-sts-3.5.0.RELEASE\MyAndroid\target\generated-sources\r -f --no-crunch -M D:\workspace-sts-3.5.0.RELEASE\MyAndroid\AndroidManifest.xml -S D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res --auto-add-overlay -A D:\workspace-sts-3.5.0.RELEASE\MyAndroid\target\generated-sources\combined-assets -I D:\Programme\androis-sdks\platforms\android-19\android.jar --output-text-symbols D:\workspace-sts-3.5.0.RELEASE\MyAndroid\target", Result = 1
[ERROR] Error when generating sources.
org.apache.maven.plugin.MojoExecutionException:
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:745)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:278)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
Caused by: com.jayway.maven.plugins.android.ExecutionException: ANDROID-040-001: Could not execute: Command = cmd.exe /X /C "D:\Programme\androis-sdks\build-tools\17.0.0\aapt.exe package -m -J D:\workspace-sts-3.5.0.RELEASE\MyAndroid\target\generated-sources\r -f --no-crunch -M D:\workspace-sts-3.5.0.RELEASE\MyAndroid\AndroidManifest.xml -S D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res --auto-add-overlay -A D:\workspace-sts-3.5.0.RELEASE\MyAndroid\target\generated-sources\combined-assets -I D:\Programme\androis-sdks\platforms\android-19\android.jar --output-text-symbols D:\workspace-sts-3.5.0.RELEASE\MyAndroid\target", Result = 1
at com.jayway.maven.plugins.android.CommandExecutor$Factory$DefaultCommandExecutor.executeCommand(CommandExecutor.java:252)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:741)
... 23 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.987 s
[INFO] Finished at: 2014-06-04T09:02:15+01:00
[INFO] Final Memory: 15M/309M
然后我从命令行以详细模式复制并执行了aapt命令,在那里我可以看到com.pekam.myandroid
中正在查找缺少的属性,而不是com.google.android.gms.R
D:\workspace-sts-3.5.0.RELEASE\MyAndroid\res\layout\multimap_demo.xml:29: error: No resource identifier found for attribute 'cameraTargetLat
' in package 'com.pekam.myandroid'
为什么编译器会查找 com.pekam.myandroid 而不是 com.google.android.gms
如何摆脱此错误
这是我的 pom xml
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pekam.myandroid</groupId>
<artifactId>myandroid</artifactId>
<version>0.1.0</version>
<packaging>apk</packaging>
<properties>
<!-- use UTF-8 for everything -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-tasks</artifactId>
<version>v1-rev33-1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.18.0-rc</version>
<exclusions>
<exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>
<exclusion>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<exclusion>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
</exclusion>
<exclusion>
<artifactId>android</artifactId>
<groupId>com.google.android</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-android</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>v2-rev70-1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev126-1.18.0-rc</version>
</dependency>
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-rest-template</artifactId>
<version>1.0.1.RELEASE</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.android</groupId> -->
<!-- <artifactId>spring-android-auth</artifactId> -->
<!-- <version>1.0.1.RELEASE</version> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-core</artifactId>
<version>1.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>maven-android-plugin</artifactId>
<configuration>
<sdk>
<path>${env.ANDROID_HOME}</path>
<platform>19</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>