我在项目的根目录下的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.project.math</groupId>
<artifactId>android-math-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Math App Android App</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.1</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>17</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
很遗憾,我遇到了错误:
[INFO] 6 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.059s
[INFO] Finished at: Tue Jan 07 19:33:06 EET 2014
[INFO] Final Memory: 18M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project android-math-app: Compilation failure: Compilation failure:
[ERROR] /Users/user/Projects/Math-Project-Appp/android-math-app/src/com/app/math/apwebview/ApWebViewJSInterface.java:[23,22] cannot find symbol
[ERROR] symbol : class JavascriptInterface
[ERROR] location: package android.webkit
[ERROR] /Users/user/Projects/Math-Project-Appp/android-math-app/src/com/app/math/apwebview/ApWebViewJSInterface.java:[38,10] cannot find symbol
[ERROR] symbol : class JavascriptInterface
[ERROR] location: class com.app.math.apwebview.ApWebViewJSInterface
[ERROR] /Users/user/Projects/Math-Project-Appp/android-math-app/src/com/app/math/apwebview/ApWebViewJSInterface.java:[44,10] cannot find symbol
[ERROR] symbol : class JavascriptInterface
[ERROR] location: class com.app.math.apwebview.ApWebViewJSInterface
[ERROR] /Users/user/Projects/Math-Project-Appp/android-math-app/src/com/app/math/apwebview/ApWebViewJSInterface.java:[49,10] cannot find symbol
[ERROR] symbol : class JavascriptInterface
[ERROR] location: class com.app.math.apwebview.ApWebViewJSInterface
[ERROR] /Users/user/Projects/Math-Project-Appp/android-math-app/src/com/app/math/apwebview/ApWebViewJSInterface.java:[61,10] cannot find symbol
[ERROR] symbol : class JavascriptInterface
[ERROR] location: class com.app.math.apwebview.ApWebViewJSInterface
[ERROR] /Users/user/Projects/Math-Project-Appp/android-math-app/src/com/app/math/apwebview/ApWebViewJSInterface.java:[68,10] cannot find symbol
[ERROR] symbol : class JavascriptInterface
[ERROR] location: class com.app.math.apwebview.ApWebViewJSInterface
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
我认为错误来自于API版本,但是自从Jelly Bean以来就支持@JavascriptInterface
,所以我不知道具体的情况...