Android Talker(2)Project Environment

Android Talker(2)Project Environment

1. Some tips about the eclipse and old project
Error Message:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources (default-generate-sources) on project ProjectName: The plugin com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1 requires Maven version [3.0.3,)

solution:
Change the version of maven from eclipse inside maven to outside maven 3.0.3.

Install the plugin android configurator for M2E with URL
Uninstall the old maven plugin and reinstall this Plugin

http://rgladwell.github.com/m2e-android/updates
http://rgladwell.github.com/m2e-android/

It is fixed.

Error Message:
case expressions must be constant expressions

solution:
Click on the red error icon, click on the tip 'migrate android code'

Put my click on switch, use command + 1, click 'convert switch to if else'

Error Message:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-jar-plugin:2.4:jar (execution:default-jar, phase: process-class)

Solution:
The pom is not the latest one, I change it as follow, it works.
<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>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<sdk>
<platform>8</platform>
</sdk>
</configuration>
<extensions>true</extensions>
</plugin>

Run the project rest client, sometimes, we need to restart the adb.
>adb \
kill-server
>adb \
start-server

Run the maven command to redeploy the latest packages to android emulator.
>mvn android:deploy
>mvn android:run

The rest server returns the JSON format data as follow:
[{"id":1,"personName":"UserName1"},{"id":2,"personName":"UserName2"}]

But I got error message as follow from getAll() List<Person> interface.

Error Message:
java.lang.ClassCastException: java.util.LinkedHashMap

Solution:
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
// Perform the HTTP GET request
Person[] persons = restTemplate.getForObject(url, Person[].class);
// convert the array to a list and return it
return Arrays.asList(persons);

2. Debug that on Real Device
>adb devices
This command will list the devices.

>adb logcat
Show the real time log on the mobile device.

I am on MAC system, and I use maven to control the android project.
The name of the sample project is EasyRestClientAndroid
>clean install android:deploy android:run

How to enable the android phone
>settings ----> applications-----> check Unknown sources
>settings ----> Development ---> check USB debugging
check stay awake
check Allow mock locations


references:
http://stackoverflow.com/questions/11031709/android-maven-plugin-3-2-0-with-maven-3-0-4-not-compile-it
http://rgladwell.github.com/m2e-android/
http://stackoverflow.com/questions/6622287/issue-when-consume-rest-service-with-resttemplate-in-desktop-app


http://thompsonng.blogspot.com/2011/08/android-debug-with-hardware-device-in.html
http://developer.android.com/tools/device.html
http://www.mkyong.com/android/android-debugging-on-real-device/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值