Migrate to Java 8 runtime

103 views
Skip to first unread message

Carlos Lee

unread,
May 31, 2018, 5:15:38 PM5/31/18
to Google App Engine
Hello,

I've received an email regarding Java 8 runtime migration of my google app engine backend.

As I understood, everything I need to know regarding java 8 migration is on this page: https://cloud.google.com/appengine/docs/standard/java/migrating-to-java8 right? 

Also, In my backend build.gradle, there are two variables:
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7


Should I need to upgrade those versions to: VERSION_1_8?

Regards

Carlos Eduardo Ki Lee





 

George (Cloud Platform Support)

unread,
May 31, 2018, 6:15:18 PM5/31/18
to Google App Engine
Hello Carlos, 

You are right, you should follow the appropriate document. 

The statements you look for are: 

sourceCompatibility = 1.8     // App Engine Flexible uses Java 8
targetCompatibility = 1.8     // App Engine Flexible uses Java 8

More detail may be gathered from the "Creating a new Gradle project" sub-chapter of the "Using Gradle and the App Engine Plugin" online document. 

Carlos Lee

unread,
Jun 1, 2018, 9:25:16 AM6/1/18
to Google App Engine
Thanxs for your help George.


I'm working on this migration task. Sorry to bother, I also need one more help.

In my backend, I'm using two imports: 
import com.google.appengine.repackaged.com.google.gson.Gson;
import com.google.appengine.repackaged.com.google.gson.GsonBuilder;
...
Gson gson = new GsonBuilder().create();


...

After I changed runtime to java8: <runtime>java8</runtime> in appengine-web.xml

this line: Gson gson = new GsonBuilder().create();

started to have:
    java.lang.NoClassDefFoundError: com/google/appengine/repackaged/com/google/gson/GsonBuilder
    1. at frolic.br.brainexercises.backend.MyEndpoint.getGameRankingV2 (MyEndpoint.java:228)


Do you have any clue why I started to have this issue?

Regards

Carlos Eduardo Ki Lee

Giuliano Ribeiro

unread,
Jun 1, 2018, 9:27:30 AM6/1/18
to Google App Engine
I faced it some time ago, you should not us the repackaged import.
Just change the import to com.google.gson.* (and of course, include the gson lib on gradle)

Carlos Lee

unread,
Jun 1, 2018, 10:11:00 PM6/1/18
to Google App Engine
Thx! Giuliano. Worked fine now.

If someone else have same problem, this is my change:

New dependency in gradle file:
compile 'com.google.code.gson:gson:2.8.1'

Imports changed:
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
//import com.google.appengine.repackaged.com.google.gson.Gson;
//import com.google.appengine.repackaged.com.google.gson.GsonBuilder;

Reply all
Reply to author
Forward
0 new messages