Java 找不到类';org.codehaus.jackson.map.ObjectMapper';,引用自方法

Java 找不到类';org.codehaus.jackson.map.ObjectMapper';,引用自方法,java,android,maven,Java,Android,Maven,我正在尝试用atmosphere框架制作一个聊天应用程序。对于这个添加依赖项的应用程序,我使用maven依赖项。 问题是,每当我试图编译包含maven依赖库的项目时,如果remove库项目运行,但它给出上述异常,则会给出错误“转换为dalvik格式失败,错误为1” 这是我的密码 public class ListenerService extends Service { private String serverIpAddress ="someIp"; private

我正在尝试用atmosphere框架制作一个聊天应用程序。对于这个添加依赖项的应用程序,我使用maven依赖项。 问题是,每当我试图编译包含maven依赖库的项目时,如果remove库项目运行,但它给出上述异常,则会给出错误“转换为dalvik格式失败,错误为1”

这是我的密码

  public class ListenerService extends Service
   {
    private String serverIpAddress ="someIp";

    private AtmosphereClient client;

    private final Handler uiHandler = new Handler();

    private final static ObjectMapper mapper = new ObjectMapper();//Exception comes here

    public static final String BROADCAST_ACTION = "Message";

    RequestBuilder request;

    public ListenerService()
    {

    }

    @Override
    public IBinder onBind(Intent intent)
    {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void onDestroy()
    {
        // TODO Auto-generated method stub
        super.onDestroy();
        Log.d("Service", "Destroyed");
    }

    @Override
    public void onCreate()
    {
        super.onCreate();
        PrefernceHelper prefernceHelper = new PrefernceHelper(this);
        String id = prefernceHelper.getPrefernce("OWNERID");
        Log.d("Service", "Id to be listened is " + id);
        startListening(id);

    }

    public void startListening(String channel)
    {
        Log.d("Service", "Inside Strat listening");
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
        client = ClientFactory.getDefault().newClient(AtmosphereClient.class);
        Log.d("Service", "Listening on " + channel);
        request = client.newRequestBuilder().method(Request.METHOD.GET).uri(serverIpAddress + "/pubsub/" + channel)
                .trackMessageLength(true)

                .encoder(new Encoder<Message, String>()
                {

                    @Override
                    public String encode(Message data)
                    {
                        Log.d("Service", "Inside encode" + data.toString());
                        try
                        {
                            return mapper.writeValueAsString(data);
                        }
                        catch (IOException e)
                        {
                            throw new RuntimeException(e);
                        }
                    }
                }).decoder(new Decoder<String, Message>()
                {

                    @Override
                    public Message decode(Event type, String data)
                    {
                        Log.d("Service", "Inside decode" + data.toString());
                        data = data.trim();

                        // Padding if (data.length() == 0) { return null; }

                        if (type.equals(Event.MESSAGE))
                        {
                            try
                            {
                                return mapper.readValue(data, Message.class);
                            }
                            catch (IOException e)
                            {
                                e.printStackTrace();
                                return null;
                            }
                        }
                        else
                        {
                            return null;
                        }
                    }
                })

                .transport(Request.TRANSPORT.WEBSOCKET);

        final org.atmosphere.wasync.Socket socket = client.create();
        socket.on("message", new Function<String>()
        {

            @Override
            public void on(final String message)
            {
                uiHandler.post(new Runnable()
                {
                    @Override
                    public void run()
                    {

                        String id = "";
                        String receviedMessage = "";
                        if (message != "")
                        {
                            try
                            {
                                JSONObject json = new JSONObject(message);
                                id = json.getString("from_id");
                                receviedMessage = json.getString("message");
                            }
                            catch (JSONException e)
                            {
                                e.printStackTrace();
                            }

                            Log.d("Service", message);
                            Intent intent = new Intent(BROADCAST_ACTION);
                            intent.putExtra("id", id);
                            intent.putExtra("message", receviedMessage);
                            sendBroadcast(intent);
                        }
                    }
                });
            }
        });
        try
        {
            socket.on(new Function<Throwable>()
            {

                @Override
                public void on(Throwable t)
                {

                }

            }).open(request.build());
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
公共类ListenerService扩展服务
{
私有字符串serverIpAddress=“someIp”;
私人大气客户端;
私有最终处理程序uiHandler=新处理程序();
private final static ObjectMapper mapper=new ObjectMapper();//这里出现异常
公共静态最终字符串广播\u ACTION=“Message”;
请求生成器请求;
公共听众服务()
{
}
@凌驾
公共IBinder onBind(意向)
{
//TODO自动生成的方法存根
返回null;
}
@凌驾
公共空间
{
//TODO自动生成的方法存根
super.ondestory();
日志d(“服务”、“销毁”);
}
@凌驾
public void onCreate()
{
super.onCreate();
PreferenceHelper PreferenceHelper=新的PreferenceHelper(此);
字符串id=PreferenceHelper.GetPreference(“OWNERID”);
Log.d(“服务”,“要监听的Id为”+Id);
监听(id);
}
公共侦听(字符串通道)
{
日志d(“服务”、“内部战略监听”);
StrictMode.ThreadPolicy policy=新建StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(策略);
client=ClientFactory.getDefault().newClient(AtmosphereClient.class);
Log.d(“服务”,“监听”+频道);
request=client.newRequestBuilder().method(request.method.GET).uri(serverIpAddress+“/pubsub/”+通道)
.trackMessageLength(真)
.encoder(新编码器()
{
@凌驾
公共字符串编码(消息数据)
{
Log.d(“服务”、“内部编码”+data.toString());
尝试
{
返回mapper.writeValueAsString(数据);
}
捕获(IOE异常)
{
抛出新的运行时异常(e);
}
}
}).decoder(新解码器()
{
@凌驾
公共消息解码(事件类型、字符串数据)
{
Log.d(“服务”、“内部解码”+data.toString());
data=data.trim();
//如果(data.length()==0){return null;}则填充
if(type.equals(Event.MESSAGE))
{
尝试
{
返回mapper.readValue(数据、消息、类);
}
捕获(IOE异常)
{
e、 printStackTrace();
返回null;
}
}
其他的
{
返回null;
}
}
})
.transport(请求.transport.WEBSOCKET);
final org.atmosphere.wasync.Socket=client.create();
socket.on(“消息”,新函数()
{
@凌驾
上的公共无效(最终字符串消息)
{
uiHandler.post(新的Runnable()
{
@凌驾
公开募捐
{
字符串id=“”;
字符串receivedMessage=“”;
如果(消息!=“”)
{
尝试
{
JSONObject json=新的JSONObject(消息);
id=json.getString(“from_id”);
receiveedMessage=json.getString(“消息”);
}
捕获(JSONException e)
{
e、 printStackTrace();
}
Log.d(“服务”,消息);
意向=新意向(广播行动);
意向。额外(“id”,id);
intent.putExtra(“消息”,receivedMessage);
发送广播(意图);
}
}
});
}
});
尝试
{
socket.on(新函数()
{
@凌驾
公共空间打开(可丢弃的t)
{
}
}).open(request.build());
}
捕获(IOE异常)
{
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
我的Pom.xml

<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">
    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>5</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.inscripts.chatproject</groupId>
    <artifactId>chatproject</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>chatproject</name>
    <url>http://github.com/Atmosphere/wasync</url>
    <scm>
        <connection>scm:git:git@github.com:Atmosphere/wasync.git</connection>
        <developerConnection>scm:git:git@github.com:Atmosphere/wasync.git</developerConnection>
        <url>http://github.com/Atmosphere/wasync</url>
    </scm>
    <prerequisites>
        <maven>2.2.0</maven>
    </prerequisites>
    <licenses>
        <license>
            <name>Apache License 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>wasync</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.ning</groupId>
            <artifactId>async-http-client</artifactId>
            <version>${ahc.version}</version>
        </dependency>
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>nettosphere</artifactId>
            <version>${nettosphere.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>atmosphere-runtime</artifactId>
            <version>${atmosphere.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>5.8</version>
            <scope>test</scope>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.3</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.5.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 or api level (api level 4 = platform 1.6) -->
                        <platform>8</platform>
                    </sdk>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${source.property}</source>
                    <target>${target.property}</target>
                    <maxmem>1024m</maxmem>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.8.1</version>
                <configuration>
                    <redirectTestOutputToFile>${surefire.redirectTestOutputToFile}</redirectTestOutputToFile>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${project.basedir}/META-INF</directory>
                        </fileset>
                        <fileset>
                            <directory>${project.basedir}/works</directory>
                        </fileset>
                        <fileset>
                            <directory>${project.basedir}/overlays</directory>
                        </fileset>
                        <fileset>
                            <directory>${project.basedir}</directory>
                            <includes>
                                <include>*.log</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <aggregate>true</aggregate>
                    <source>1.6</source>
                    <encoding>UTF-8</encoding>
                    <maxmemory>1g</maxmemory>
                    <links>
                        <link>http://java.sun.com/javase/6/docs/api/</link>
                    </links>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <outputDirectory>target/site</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <aggregate>true</aggregate>
                    <debug>true</debug>
                    <links>
                        <link>http://docs.oracle.com/javaee/6/docs/api/</link>
                        <link>http://docs.oracle.com/javase/6/docs/api/</link>
                    </links>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>project-team</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
    <repositories>
        <repository>
            <id>oss.sonatype.org</id>
            <url>http://oss.sonatype.org/content/repositories/releases</url>
        </repository>
        <repository>
            <id>oss.sonatype.org-snapshot</id>
            <url>http://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </repositories>
    <distributionManagement>
        <repository>
            <id>sonatype-nexus-staging</id>
            <name>Sonatype Release</name>
            <url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>sonatype-nexus-snapshots</name>
            <url>${distMgmtSnapshotsUrl}</url>
        </snapshotRepository>
    </distributionManagement>
    <properties>
        <distMgmtSnapshotsUrl>http://oss.sonatype.org/content/repositories/snapshots</distMgmtSnapshotsUrl>
        <surefire.redirectTestOutputToFile>false</surefire.redirectTestOutputToFile>
        <source.property>1.6</source.property>
        <target.property>1.6</target.property>
        <atmosphere.version>2.0.0.RC3</atmosphere.version>
        <nettosphere.version>2.0.0.RC4</nettosphere.version>
        <ahc.version>1.7.19</ahc.version>
    </properties>
</project>

org.sonatype.oss
oss父级
5.
4.0.0
com.inscript.chatproject
聊天项目
1.0.0-SNAPSHOT
apk
聊天项目
http://github.com/Atmosphere/wasync
scm:git:git@github.com:Atmosphere/wasync.git
scm:git:git@github.com:Atmosphere/wasync.git
http://github.com/Atmosphere/wasync
2.2.0
Apache许可证2.0
http://www.apache.org/licenses/LICENSE-2.0.html
回购