Android Question GoogleApiAvailability Issue on New Android SDK GUI

Azam Memon

Member
Licensed User
I am using Firebase Analytics and Firebase Ads services in my app.

Before B4A version 7.8, I was using old GUI based Android SDK Manager and my code was working fine. I have updated to B4A version 7.8 and used new Android SDK available with B4A 7.8 and installed all recommended as well as other tools like Google Repository, Google APIs v20, and Google Play Services.

My app is compiling and when I am running my app on Android Device, I am getting an error about ClassNotFoundException.

B4X:
*** Service (starter) Create ***
starter_checkforgoogleplayservices (java line: 178)
java.lang.ClassNotFoundException: com.google.android$gms$common$GoogleApiAvailability
    at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:288)
    at anywheresoftware.b4j.object.JavaObject.InitializeStatic(JavaObject.java:74)
    at com.galaxy.wireless_conversation.starter._checkforgoogleplayservices(starter.java:178)
    at com.galaxy.wireless_conversation.starter._service_create(starter.java:548)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at com.galaxy.wireless_conversation.starter.onCreate(starter.java:55)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3807)
    at android.app.ActivityThread.access$2100(ActivityThread.java:223)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1882)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:7223)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
java.lang.RuntimeException: Unable to create service com.galaxy.wireless_conversation.starter: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.google.android$gms$common$GoogleApiAvailability
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3817)
    at android.app.ActivityThread.access$2100(ActivityThread.java:223)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1882)
    at android.os.Handler.dispatchMessage(Handler.java:102)

But when I changed the Android.jar location from new Android SDK Manager (came with B4A 7.8) to old Android SDK Manager, the same code without any changes works fine.

On new SDK Manager, I am getting another Exception:

B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'void java.net.DatagramSocket.send(java.net.DatagramPacket)' on a null object reference
    at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket$1.run(SocketWrapper.java:479)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
I guess I am missing something, which is required to be installed in the new SDK Manager.
 
Top