Android Question Problems after updating to Google Play Service V17

marcick

Well-Known Member
Licensed User
Longtime User
Hi all,
my app was working fine, but after this update to V17, the code

"If MapFragment1.IsGooglePlayServicesAvailable = False Then"

generate this error:

java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 but found 4452000. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
at anywheresoftware.b4a.objects.MapFragmentWrapper.IsGooglePlayServicesAvailable(MapFragmentWrapper.java:101)

I have some difficutlies working with manifest, which is the exact sintax to add that declaration in the manifest ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I see it too. I'm investigating it. For now you can force the version by replacing @integer/google_play_services_version with 4323000:

B4X:
AddApplicationText(<meta-data
  android:name="com.google.android.maps.v2.API_KEY"
  android:value="AIzaSyxxx"/>
   <meta-data android:name="com.google.android.gms.version"
   android:value="4323000" />
   )

Make sure to update google-play-services.jar in the additional libraries folder.
 
Last edited:
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
re copy librerie Google play after updating!

if you mean

"Copy google-play-services.jar to the libraries folder"

I did it after update but still have the error.

Erel solution works, thanks

edit: oops .... I copied the library to the additional library folder instead of the b4a library folder. Now I did it correctly and it works, no need to add that code to the manifest.
Thanks both again

edit again .... it seems that now is impossible to compile in debug mode (only release works):

Parsing code. 0.22
Compiling code. 1.69
Compiling layouts code. 0.35
Generating R file. 0.56
Compiling generated Java code. 6.74
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.cf.code.ByteCatchList.toRopCatchList(ByteCatchList.java:210)
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:691)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:653)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:266)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:282)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
at com.android.dx.command.dexer.Main.processClass(Main.java:682)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:170)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
Optimized dexer failed. Switching to Standard dexer.
 
Last edited:
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
"library folder", not "additional library"

About the problem compiling in debug mode (that I initially solved increasing MaxRamForDex to 1536), I have uninstalled the SDK and reinstalled again in the path C:\Andoid-Sdk (it was before in c:\programs ....) and now it works correctly, no need to modify MaxRamForDex to 1536.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
True ..
I don't know what was happening on my pc before, perhaps the wrong path of Android-Sdk was the cause of everything
 
Upvote 0

holdemadvantage

Active Member
Licensed User
Longtime User
Hi all, please help me.
1- i have downloaded with sdk manager GPS rev 17, my sdk is in c:\Android folder
2-i've added this line to my project
#AdditionalRes: C:\Android\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
3-i've added admob 2.0 lib, google play service jar was copied into additional libraries folder
when i want to to compile (release obfuscated) all was ok but i had an error trying to compile in debug mode
4-i change MaxRamForDex=1536

Now after this change i restart my pc and now i have this error trying to compile (release obfuscated):

Parsing code. 0.11
Compiling code. 0.19
Compiling layouts code. 0.14
Generating R file. 0.29
Compiling generated Java code. 2.74
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.Arrays.copyOfRange(Arrays.java:2694)
at java.lang.String.<init>(String.java:203)
at java.lang.StringBuilder.toString(StringBuilder.java:405)
at com.android.dx.rop.type.Prototype.withFirstParameter(Prototype.java:370)
at com.android.dx.rop.code.Rops.ropFor(Rops.java:1210)
at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:477)
at com.android.dx.cf.code.Simulator$SimVisitor.visitConstant(Simulator.java:691)
at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:764)
at com.android.dx.cf.code.Simulator.simulate(Simulator.java:94)
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:698)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:653)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:266)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:282)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
at com.android.dx.command.dexer.Main.processClass(Main.java:682)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
Optimized dexer failed. Switching to Standard dexer.

Edit: increasing MaxRamForDex to 1536 solves the problem, i did it when b4a was open (i didn't thought i have to change it when b4a was closed)
 
Last edited:
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I have to tell you that I had the same problem, solved too increasing MaxRamForDex to 1536.
Then, I uninstalled everything and reinstalled The SDK and B4A from zero and everything worked fine, without increasing that RAM value.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Edit: increasing MaxRamForDex to 1536 solves the problem, i did it when b4a was open (i didn't thought i have to change it when b4a was closed)
You should update this field when the IDE is closed. Otherwise it will be overwritten when you close the IDE (the INI file is rewritten at that point).
 
Upvote 0

Gentry

Member
Licensed User
Longtime User
I was having challenges with v20 of play services. Luckily I had an old version of the jar file in a backup (apparently once you upgrade you can't go back). Did the following with v20 before giving up:

EDIT: Using v3.82

1) Copied new google-play-services.jar to my addons directory (tried the libraries folder 1st)

2) Added
B4X:
#AdditionalRes: {mypath}\google-play-services_lib\res, com.google.android.gms to the project properties

3) Added my API key and this to the manifest
B4X:
AddManifestText( <permission
          android:name="$PACKAGE$.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/>
      <uses-feature android:glEsVersion="0x00020000" android:required="true"/>)
AddApplicationText(<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="MyAPIKey"/>)

AddApplicationText(<meta-data
   android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" />)
  
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(com.google.android.providers.gsf.permission.READ_GSERVICES)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)

4) Even tried hard coding the version (6111000 for v20 per the src\values file) in the manifest

But I kept getting
B4X:
java.lang.NoClassDefFoundError: anywheresoftware.b4a.objects.MapFragmentWrapper$MyMapFragment
    at anywheresoftware.b4a.objects.MapFragmentWrapper.Initialize(MapFragmentWrapper.java:115)
    at com.gmansoft.MissonMan.mapdisplay._activity_create(mapdisplay.java:325)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at com.gmansoft.MissonMan.mapdisplay.afterFirstLayout(mapdisplay.java:98)
    at com.gmansoft.MissonMan.mapdisplay.access$100(mapdisplay.java:16)
    at com.gmansoft.MissonMan.mapdisplay$WaitForLayout.run(mapdisplay.java:76)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:157)
    at android.app.ActivityThread.main(ActivityThread.java:5867)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
    at dalvik.system.NativeStart.main(Native Method)

Like I said I was successful by using an old google-play-services.jar, but if your going for v20, there may be challenges.
 
Last edited:
Upvote 0

Gentry

Member
Licensed User
Longtime User
I think so, it's pointing to C:\Program Files\Java\jdk1.7.0_25\bin\javac.exe about says version 7 rev 21.
 
Upvote 0
Top