Maven和Android - 找不到符号

时间:2021-10-05 10:42:18

I have the following build configuration in my pom.xml which is located in the root of my project:

我在我的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>

but unfortunately I get the error:

但不幸的是我得到了错误:

[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

I thought that the error comes from the API version but @JavascriptInterface is supported since Jelly Bean so I have no idea what is the case...

我认为错误来自API版本,但自Jelly Bean以来支持@JavascriptInterface所以我不知道是什么情况......

1 个解决方案

#1


0  

You'll need to find another annotations dependency, as the com.google.android:android:4.1.1.4 doesn't contain any class named JavascriptInterface (the com.google.android:annotations:4.1.1.4 neither).

您需要找到另一个注释依赖项,因为com.google.android:android:4.1.1.4不包含任何名为JavascriptInterface的类(com.google.android:annotations:4.1.1.4也没有)。

This maven repository search will give you all jars containing the JavascriptInterface.

这个maven存储库搜索将为您提供包含JavascriptInterface的所有jar。

#1


0  

You'll need to find another annotations dependency, as the com.google.android:android:4.1.1.4 doesn't contain any class named JavascriptInterface (the com.google.android:annotations:4.1.1.4 neither).

您需要找到另一个注释依赖项,因为com.google.android:android:4.1.1.4不包含任何名为JavascriptInterface的类(com.google.android:annotations:4.1.1.4也没有)。

This maven repository search will give you all jars containing the JavascriptInterface.

这个maven存储库搜索将为您提供包含JavascriptInterface的所有jar。