私は大気フレームワークでチャットアプリケーションを作ろうとしています.この依存関係を追加するために、私はmaven依存関係を使用しています. 問題は、maven 依存関係ライブラリが含まれているプロジェクトをコンパイルしようとするたびに、ライブラリ プロジェクトを削除すると「エラー 1 で dalvik 形式への変換に失敗しました」というエラーが発生しますが、上記の例外が発生します。
これが私のコードです。
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();
}
}
私の 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>