私はMavenとSpringResttemplateを使用してAndroidアプリケーションを開発しています。
これは私のpom.xmlです
<properties>
<platform.version> 2.3.3</platform.version>
<spring.version>1.0.0.RELEASE</spring.version>
<simple-version>2.4.1</simple-version>
</properties>
<dependencies>
<!-- Spring Android Core -->
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-core</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring Rest Android -->
<dependency>
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-rest-template</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Using Jackson for JSON marshaling -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.7.1</version>
</dependency>
<!-- Using Simple for XML marshaling -->
<dependency>
<groupId>org.simpleframework</groupId>
<artifactId>simple-xml</artifactId>
<version>${simple-version}</version>
<exclusions>
<exclusion>
<artifactId>stax</artifactId>
<groupId>stax</groupId>
</exclusion>
<exclusion>
<artifactId>stax-api</artifactId>
<groupId>stax</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>10</platform>
</sdk>
<emulator>
<avd>10</avd>
</emulator>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
メインアクティビティでは、このコードをボタンに入れています:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnLogin = (Button) findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String email = "user@xxxx.com";
String passwd = "123456";
restTemplate = new RestTemplate();
try {
Users user = restTemplate.getForObject(URL + "/{email}/{password}",
Users.class, email, passwd);
if (user != null) {
System.out.println("Mi nombre es: " + user);
}
} catch (ResourceAccessException ex) {
System.out.println("OFF");
} catch (RestClientException ex) {
System.out.println("Error");
}
}
});
アプリケーションをデバイスに実行すると、これはlogCatに表示されるエラーです。
java.lang-IllegalArgumentException: 'messageConverters' must not be empty
ありがとう!!!!