Thursday, July 31, 2014

Dex Loader Error - Generate Google App Engine Backend

There is an error occurred after generate Google App Engine Backend for an existing android project.

Unable to execute dex: Multiple dex files define Lcom/google/api/client/googleapis/extensions/android/accounts/GoogleAccountManager;

I took me hours to figure out what the problem was.

The problem was my app had already added these google jars for my existing coding and developement

C:\WorkSpace\myapp\libs\google-api-client-1.15.0-rc.jar
C:\WorkSpace\myapp\libs\google-api-client-android-1.15.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-1.15.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-android-1.15.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-gson-1.15.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-jackson-1.15.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-jackson2-1.15.0-rc.jar
C:\WorkSpace\myapp\libs\google-oauth-client-1.15.0-rc.jar

But, the GPE kept adding these jars into my library

C:\WorkSpace\myapp\libs\google-api-client-1.18.0-rc.jar
C:\WorkSpace\myapp\libs\google-api-client-android-1.18.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-1.18.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-android-1.18.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-gson-1.18.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-jackson2-1.18.0-rc.jar
C:\WorkSpace\myapp\libs\google-http-client-jdo-1.18.0-rc.jar
C:\WorkSpace\myapp\libs\google-oauth-client-1.18.0-rc.jar

I removed conflicting jars by deleting those jars in version 1.15. Mission accomplished.





Tuesday, July 29, 2014

The use of ASP pages will be supported on Windows 8 for a minimum of 10 years from the Windows 8 release date.

Official announcement from Microsoft

http://support.microsoft.com/kb/2669020 

Active Server Pages (ASP) enables Web servers to dynamically generate Web pages and create interactive Web applications by using server-side scripting technology. The use of ASP pages with Internet Information Services (IIS) is currently supported on all supported versions of IIS.

The next major version of Internet Information Services (IIS) will be shipped as part of the Windows 8 operating system. The use of ASP pages will be supported on Windows 8 for a minimum of 10 years from the Windows 8 release date.

Monday, July 28, 2014

PMP (4th edition) mock exam

Here is a PMP mock exam questions generator based on the PMBOK guide 4th edition, with answers at the end of page)

Hope it is helpful to any one who would like or is going to take the exam. Good luck!

http://xcoder10.brinkster.net/pmp/default.asp

CodeReady

CodeReady is database client + ASP page generator written in Visual Basic in 2005.  I published the program to download.com at the end of 2006. I created a video for demonstrating function and features



https://www.youtube.com/watch?v=52BJn6INJ6Q

The program can still run on Windows 8.1, troublefree!

Download link: http://download.cnet.com/Code-Ready/3000-10254_4-10473550.html


Sunday, July 27, 2014

noclassdeffounderror, PhoneNumberUtil & Google App Engine

PhoneNumberUtil is not a supported class in GAE. Simply adding the jar into the jre/lib/ext will let you through the compilation, but you probably will get a java.lang.noclassdeffounderror after deployment.

The problem cannot be solved through Eclipse interface. What I do is to, first, copy the jar (mine one is libphonenumber-6.2.jar) to war\WEB-INF\lib, and then add the jar to build path in the project explorer.

This solution also works for other external jars.

To download PhoneNumberUtil, go to https://code.google.com/p/libphonenumber/.  

Mission accomplished!

Connecting Google Cloud SQL via mySQL ODBC database driver in Windows 8.1

There are 3 things you have to do in the "Access control" of the Cloud SQL instance
  1. Request an IP of the Cloud SQL instance. P.S. It costs you $0.01 per hour if there is an IP address assign to an idle instance
  2. Set a root password
  3. Provide IP address of the authorized network, usually it means to IP address of your workstation or server.

After that, get the ODBC database driver handy, you may download the driver via this link, your choice of 32/64bits


Next, configure the ODBC driver, enter the IP address provided by Google. You may test the connection by pressing the test button.


All things done, you are on.

I can even connect my Cloud SQL instance through my homebrew database client + ASP code generator created in early years.  You may still find my program published on download.com here. It works on 32bits driver only.


Tears coming out of my eyes

Calling GCM by using ASP classic

function sendToGCM(regIds, metaData)

'http://developer.android.com/google/gcm/http.html

Dim DataToSend

DataToSend = DataToSend & "registration_id=" & regids
DataToSend = DataToSend & "&collapse_key=location"
DataToSend = DataToSend & "&data.location=" & metaData

Dim key
key = "AdisfbsisP5MwE389fjnsidsslpx10fm2siusbi8bwc" 'Generated server key for the application

url = "https://android.googleapis.com/gcm/send"

set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
    xmlhttp.open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"
'Public API Server Key
xmlhttp.setRequestHeader "Authorization", "key=" & key
xmlhttp.send DataToSend
    returnString = xmlhttp.responseText
    set xmlhttp = nothing

sendToGCM = returnString

end function

Using Google Cloud SQL with App Engine in JAVA

Excellent demo, interesting tone
Now, I am going through this tutorial

https://developers.google.com/appengine/docs/java/cloud-sql/#Java_Connect_to_your_database


Database table created. There is a SQL prompt in the Google Cloud SQL

Through almost 2 days of work, I finished. There are a few things worth mentioning
  1. A JDK is required to compile JSPs to be uploaded to GAE. Should pay attention to the JDK version as GAE, currently, supports up to JAVA7. If the JSP is compiled in JAVA8, it will not work in the GAE. If you have a 64-bits Eclipse running, you require a JDK in 64-bits

    If you have the JDK installed properly, but you still have the UnsupportedClassVersionError from the GAE,  there are few things you have to do to make sure your app is correctly compiled.

    UnsupportedClassVersionError

    Unsupported major.minor version 52.0, java.lang.UnsupportedClassVersionError: org/apache/jsp/test1_jsp : Unsupported major.minor version 52.0

    If you do not require any other JRE to be run on your machine, uninstall all other JREs and JDKs. This would save you bundle of time for dragging yourself into a build path chaos

    If you require multiple JREs and JDKs to be run on a same machine, check your environment variables in the Control panel > Systems > Environment Variables. Make sure the path is pointing to the bin of the JDK for compilation.

  1. A Cloud SQL instance can be setup in region either US, EU or Asia. If you intended to authorise your GAE app to connect to the Google Cloud SQL, they must be in the same region. Otherwise, you get a "Authorized GAE applications must be in the same region as the database instance" error.  The region setting cannot be changed once the database instance is created, and as far a I know, Google allows GAE app to be created and run in US only. 

Friday, July 25, 2014

Google Cloud Datastore



A really good video to begins with

https://developers.google.com/datastore/docs/concepts/overview

Reasons for not voting Datastore, for now
  1. A new product, not an industrial standard yet
  2. Maintenance and management
    GQL is read-only query, using API to update or remove kind, entity is a non-trivial task so far
  3. Requires a learning-curve for RDB developers
  4. Support and reliability
  5. Provider and pricing, obviously Google only

Pricing

It's important to note that data stored in the datastore may incur significant overhead. This overhead depends on the number and types of associated properties, and includes space used by built-in and custom indexes. Each entity stored in the datastore requires the following metadata:
  • The entity key, including the kind, the ID or key name, and the keys of the entity's ancestors.
  • The name and value of each property. Since the datastore is schemaless, the name of each property must be stored with the property value for any given entity.
  • Any built-in and custom index rows that refer to this entity. Each row contains the entity kind, any number of property values depending on the index definition, and the entity key.
See How Entities and Indexes are Stored for a complete breakdown of the metadata required to store entities and indexes at the Bigtable level and How Index Building Works for a detailed explanation of how datastore indexes are managed.
ResourceFree Default Daily LimitBilling Enabled Default Limit
Stored Data (billable)1 GB*1 GB free; no maximum
Number of Indexes200*200
Write Operations50,00010 million per day**
Read Operations50,00010 million per day**
Small Operations50,00010 million per day**
*Not a daily limit but a total limit.
**The billing enabled limits are for Preview only. If you expect to exceed these limits while the service is in Preview please request a quota increase.

Wednesday, July 23, 2014

Mission accomplished - Testing and Deploying Endpoints with App Engine

Hooray, all things done, successfully creating an entity in my app engine through my android app.



Reinstalling Eclipse

I've figured out the ultimate solution to deal with this chaos, backup the adt sdk and workspace, and then reinstall the Eclipse.

After the lengthy download of the latest ADT SDK, I got tons of errors to deal with....


I still have a long long way to go...... Going to download old android SDKs, Eclipse is an evil time-eating monster


Tuesday, July 22, 2014

Generate Cloud Endpoint Client Library

Aging, this buggy, troublesome, terrible ..... Eclipse brings another nightmare to me.














I followed each steps carefully in the tutorial, and I even couldn't find the error log in Eclipse yet.



Where is the Error Log exactly?

Okay, eventually, I found the log file in my workspace C:\WorkSpace\.metadata

I must admit Eclipse has broken all my personal records, and has become the worst and the most unproductive IDE at all times.

The exact error is .... holy sh*t

!ENTRY com.google.gdt.eclipse.core 4 0 2014-07-22 17:17:30.983
!MESSAGE Unexpected Exception
!STACK 0
java.lang.NullPointerException
at com.google.gdt.eclipse.suite.ext.update.UpdateSiteURLGenerator.computeCompositeUpdateSiteURL(UpdateSiteURLGenerator.java:221)
at com.google.gdt.eclipse.suite.ext.update.UpdateSiteURLGenerator.generateEndpointsClassURL(UpdateSiteURLGenerator.java:121)
at com.google.gdt.eclipse.suite.ext.update.UpdateSitePingManager.sendGenEndpointsClassPing(UpdateSitePingManager.java:115)
at com.google.gdt.eclipse.suite.ext.update.EndpointsUsageReporter.onGenerateEndpointClass(EndpointsUsageReporter.java:30)
at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiClassAction$1.run(GenerateSwarmApiClassAction.java:115)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

!ENTRY com.google.gdt.eclipse.appengine.swarm 4 0 2014-07-22 17:17:34.060
!MESSAGE Unexpected Exception
!STACK 0
java.lang.reflect.InvocationTargetException
at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiClassAction$1.run(GenerateSwarmApiClassAction.java:118)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.lang.NullPointerException
at com.google.gdt.eclipse.suite.ext.update.UpdateSiteURLGenerator.computeCompositeUpdateSiteURL(UpdateSiteURLGenerator.java:221)
at com.google.gdt.eclipse.suite.ext.update.UpdateSiteURLGenerator.generateGaeBackendDeployURL(UpdateSiteURLGenerator.java:78)
at com.google.gdt.eclipse.suite.ext.update.AnalyticsPingManager.projectDetailsString(AnalyticsPingManager.java:183)
at com.google.gdt.eclipse.suite.ext.update.AnalyticsPingManager.sendGenEndpointsClassPing(AnalyticsPingManager.java:143)
at com.google.gdt.eclipse.suite.ext.update.EndpointsUsageReporter.onGenerateEndpointClass(EndpointsUsageReporter.java:31)
at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiClassAction$1.run(GenerateSwarmApiClassAction.java:115)
... 1 more
Root exception:
java.lang.NullPointerException
at com.google.gdt.eclipse.suite.ext.update.UpdateSiteURLGenerator.computeCompositeUpdateSiteURL(UpdateSiteURLGenerator.java:221)
at com.google.gdt.eclipse.suite.ext.update.UpdateSiteURLGenerator.generateGaeBackendDeployURL(UpdateSiteURLGenerator.java:78)
at com.google.gdt.eclipse.suite.ext.update.AnalyticsPingManager.projectDetailsString(AnalyticsPingManager.java:183)
at com.google.gdt.eclipse.suite.ext.update.AnalyticsPingManager.sendGenEndpointsClassPing(AnalyticsPingManager.java:143)
at com.google.gdt.eclipse.suite.ext.update.EndpointsUsageReporter.onGenerateEndpointClass(EndpointsUsageReporter.java:31)
at com.google.gdt.eclipse.appengine.swarm.wizards.GenerateSwarmApiClassAction$1.run(GenerateSwarmApiClassAction.java:115)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

After spending a whole day, I decided to download the latest ADT SDK, and finally I could build my every first endpoints class by using the GPE. In addition, I found the error log


Yet, Eclipse won't let my headache go away. For sure, I have to reset and download all libraries, and, this time, the AVD manager and the SDK manager were gone missing in Eclipse interface.

Requesting location by SMS

Struggling with the location request through SMS for a long long time. It seems to be simple and straight forward, but, in fact, it is not as easy as I thought. There is only one chance (SMS) to return the most accurate location to the sender.

What I have changed to the app is

  1. Tried to save some precious battery for not connecting the network if the GPS is turned on, but seems did not work out.

    The appropriate way is first check the status of GPS (on/off) and check if GPS signal is available. Will apply that in later stage.

    Currently, connect to the network regardless the GPS is on or not. The GPS is turned on, but the GPS signal could be unavailable. The location acquired, therefore, is out-dated.



  • private void connectNetworkBySMS()

    1.     {    
    2.    
    3.     if(appSettings.getBoolean(AppSettings.Key_SMS_MobileData, false))
    4.     {
    5.     enableMobileData();
    6.     }
    7.    
    8.     if(appSettings.getBoolean(AppSettings.Key_SMS_Wifi, false))
    9.     {
    10.     enableWifi();
    11.     }
    12.    
    13.     isWaitingForResponse = true;
    14.    
    15.     }
    2. Validate contact for code #10 or #STATUS only, proceed other information without validation
      1. if((code.indexOf("#10")!=-1||code.indexOf("#STATUS")!=-1)
      2.      &&
      3.       appSettings.getBoolean(AppSettings.Key_SMS_AllowSMSRequest, false)
      4.        &&contactsManager.IsTrusted(userId))
      5.       {
      6.      connectNetworkBySMS(); 
      7.      queuelRequest(userId);   
      8.       }
      9.       if(code.indexOf("#BEGIN")!=-1 && code.indexOf("#END")!=-1)
      10.       {     
      11.      Position p = updatePositionDB(senderNum, code);
      12.       }
      Okay, that's all for today, good night!

      Monday, July 21, 2014

      The import com.google.api.client.json.jackson cannot be resolved

      So far so good, but now what?

      https://developers.google.com/eclipse/docs/endpoints-addentities



      The solution is here, change jackson to jackson2 in this piece of cripple source code.

      import com.google.api.client.json.jackson2.JacksonFactory;


      Endpoints and AppEngine


      Going to build an app engine to replace my current backend running on a ASP server.





      First thing first, get the things I need for my Eclipse JUNO

      Next, go through the tutorial

      Applying SMA10/20, SMA20/50 as trading signals

      This is the comparison for results before and after applying SMA10/20 and SMA20/50 in the stock trader. Background Trading 3 stock ma...