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. com.jayway.maven.plugins.android.generation2 android-maven-plugin 3.1.1 ${project.basedir}/AndroidManifest.xml ${project.basedir}/assets ${project.basedir}/res ${project.basedir}/src/main/native true true 8 true 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 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/