MagicFoundation / Alcinoe

Alcinoe Component Library For Delphi. Full opengl video player, WebRTC delphi wrapper, native ios/android TEdit, Improuved firemonkey controls, Firebase cloud messaging, Android/ios facebook sdk login, Json/Bson Parser, ImageMagick wrapper, MongoDb client And much more
Apache License 2.0
989 stars 220 forks source link

Apps containing FacebookAPI crash when deployed to Play Store as AAB (now a requirement) #145

Closed pimmie78 closed 1 week ago

pimmie78 commented 4 years ago

If you build an app (or use the ALFacebookLogin demo app) and run directly onto the device in debugging mode (Android64 build) it works properly and the Facebook login is triggered as expected.

If the same app is built for Play Store as an app bundle, the deployed app crashes as soon as the Facebook API is invoked due to a missing reference. Details below.

To reproduce:

Logcat includes the following error:

E/AndroidRuntime(32277): FATAL EXCEPTION: main E/AndroidRuntime(32277): Process: com.ALFacebookLogin.app, PID: 32277 E/AndroidRuntime(32277): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ALFacebookLogin.app/com.facebook.FacebookActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f04001d type #0x1c is not valid E/AndroidRuntime(32277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3632) E/AndroidRuntime(32277): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3784) E/AndroidRuntime(32277): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) E/AndroidRuntime(32277): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) E/AndroidRuntime(32277): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) E/AndroidRuntime(32277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2270) E/AndroidRuntime(32277): at android.os.Handler.dispatchMessage(Handler.java:107) E/AndroidRuntime(32277): at android.os.Looper.loop(Looper.java:237) E/AndroidRuntime(32277): at android.app.ActivityThread.main(ActivityThread.java:8125) E/AndroidRuntime(32277): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(32277): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) E/AndroidRuntime(32277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100) E/AndroidRuntime(32277): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f04001d type #0x1c is not valid E/AndroidRuntime(32277): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2388) E/AndroidRuntime(32277): at android.content.res.Resources.getLayout(Resources.java:1276) E/AndroidRuntime(32277): at android.view.LayoutInflater.inflate(LayoutInflater.java:532) E/AndroidRuntime(32277): at android.view.LayoutInflater.inflate(LayoutInflater.java:481) E/AndroidRuntime(32277): at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:541) E/AndroidRuntime(32277): at android.app.Activity.setContentView(Activity.java:3369) E/AndroidRuntime(32277): at com.facebook.FacebookActivity.onCreate(FacebookActivity.java:78) E/AndroidRuntime(32277): at android.app.Activity.performCreate(Activity.java:7957) E/AndroidRuntime(32277): at android.app.Activity.performCreate(Activity.java:7946) E/AndroidRuntime(32277): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) E/AndroidRuntime(32277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3607) E/AndroidRuntime(32277): ... 11 more

It seems that the post-build script which includes the necessary R file details may be interfered with during the bundling process.

This means that the Facebook API (and maybe others) in this package can't be used in a production Android app until this is fixed.

To reproduce, use the ALFacebookLogin app and build as described above with a Keystore file.

The commands I used to extract the relevant "app" from the bundle and install onto the connected device to mimic the Play Store deployment are as follows. This is exactly as per Google's official instructions:

Note - these commands should be run from the \bin folder where the .aab is generated.

"C:\Program Files\Java\jdk1.8.0_60\bin\java.exe" -jar "c:\program files (x86)\embarcadero\studio\20.0\bin\android\bundletool-all-0.10.3.jar" build-apks --connected-device --bundle=ALFacebookLogin.aab --output=extracted.apks --adb=C:\SDKs\android-sdk-windows\platform-tools\Adb.exe --ks=........\release.keystore --ks-pass=pass:Password1 --ks-key-alias=alcinoe --key-pass=pass:Password1

"C:\Program Files\Java\jdk1.8.0_60\bin\java.exe" -jar "c:\program files (x86)\embarcadero\studio\20.0\bin\android\bundletool-all-0.10.3.jar" install-apks --apks=extracted.apks

LeeHyunChul777 commented 3 years ago

Is the only Facebook API an issue?

Is there any problem with other components such as TALText TALRectangle?

LeeHyunChul777 commented 3 years ago

I just tested it too. [DELPHI 10.3.3]

  1. Add ALText and ALRectangle to the blank form.

  2. Android 64bit-Application Store Mode & [aab option checked] Build Run.

  3. Project1.aab was created.

  4. Command execution java -jar "C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\Android\bundletool-all-0.10.3.jar" build-apks --bundle="Project1.aab" --output=extracted .apks --adb="C:\Users\Public\Documents\Embarcadero\Studio\20.0\CatalogRepository\AndroidSDK-2525_20.0.36039.7899\platform-tools\adb.exe" --ks="D:\test\ testtt\key\mykey.keystore" --ks-pass=pass:tfod777 --ks-key-alias=mykey --key-pass=pass:tfod777

  5. extracted.apks are created (32bit & 64bit included)

  6. Run test on Android7 Android10

  7. Perfect operation

armeabi_v7a.apk & arm64_v8a.apk files... all ok!

Zeus64 commented 1 week ago

Hello, everything has been fixed in the latest committed version.