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/

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android名词解释
  2. [Android Pro] Android的5个进程等级
  3. Android studio 提取文件指定字符串
  4. android sdk manager 闪退 打不开问题
  5. ListView的一些属性设置
  6. Android企业客户端开发实战视频汇总
  7. [Android] Android Tweened Animations动
  8. Android开发:MPAndroidChart的配置和使用
  9. Android Studio 下载 与 安装 详细步骤
  10. Android 系统搜索框(有浏览记录)