[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project com.xx.xx1: Compilation failure
[ERROR] /src/com/abc/exam/ChapterActivity.java:[282,52] cannot find symbol
[ERROR] symbol : class Chapter
[ERROR] location: class com.abc.exam.ChapterActivity`
ChapterActivity.java
package com.abc.exam;
import com.abc.exam.ChapterActivity.ChapterAdapter.ViewHolder;
import com.abc.exam.dm.Chapter;
public class ChapterActivity extends ListActivity {
public class ChapterAdapter extends ArrayAdapter<Chapter> {
public class ViewHolder {
}
}
}
ChapterAdapter是ChapterActivity中的内部类。
ChapterActivity和Chapter不在同一个包中,但引入了Chapter包。 我很想知道它是如何失败的,我做了一个测试
(1)改变如此ArrayAdapter<abc.exam.dm.Chapter>
,它的构建正常。
当我
(2)将章节移动到与ChapterActivity相同的包中,也没关系。
(3)只需将内部类ChapterAdapter放在一边,它也可以构建好。
(4)删除包'import com.abc.exam.ChapterActivity.ChapterAdapter.ViewHolder;'它也没关系
(5)更改导入包位置
import com.abc.exam.dm.Chapter;
import com.abc.exam.ChapterActivity.ChapterAdapter.ViewHolder;
没关系。
所以我们可以弄清楚,这是一个构建依赖(泛型类型,Circle依赖,内部类)问题。
的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>
<artifactId>com.abc.exam</artifactId>
<groupId>com.abc</groupId>
<version>2.7.3-SNAPSHOT</version>
<packaging>apk</packaging>
<name>PigExam</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.madhouse.android.ads</groupId>
<artifactId>smartmad-sdk-android.jar</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/smartmad-sdk-android.jar</systemPath>
</dependency>
<dependency>
<groupId>com.admogo</groupId>
<artifactId>AdsMOGO-SDK-Android.jar</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/AdsMOGO-SDK-Android.jar</systemPath>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0-alpha-14</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src</nativeLibrariesDirectory>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6) -->
<path>/android/android-sdk-linux</path>
<platform>10</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerVersion>1.6</compilerVersion>
<fork>true</fork>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>