Android Question Problems Facebook v2.00 B4A 12.0 Beta

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
*** Service (starter) Create ***
Error occurred on line: 19 (Starter)
The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
at com.facebook.internal.Validate.sdkInitialized(Validate.kt:129)
at com.facebook.login.LoginManager.<init>(LoginManager.kt:1398)
at com.facebook.login.LoginManager$Companion.getInstance(LoginManager.kt:1319)
at com.facebook.login.LoginManager.getInstance(Unknown Source:2)
at anywheresoftware.b4x.objects.FacebookSdkWrapper.Initialize2(FacebookSdkWrapper.java:91)
at anywheresoftware.b4x.objects.FacebookSdkWrapper.Initialize(FacebookSdkWrapper.java:81)
at com.ionverse.vango.taxis.starter._service_create(starter.java:335)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at com.ionverse.vango.taxis.starter.onCreate(starter.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4013)
at android.app.ActivityThread.access$1600(ActivityThread.java:226)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1905)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:225)
at android.app.ActivityThread.main(ActivityThread.java:7564)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

** Service (starter) Start **

As per steps given here: https://www.b4x.com/android/forum/threads/facebook-extends-firebaseauth-to-support-facebook.67954/
 

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
Have you updated the manifest code? This error happens when the provider declaration is missing.
Yes, this is exactly my manifest

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@style/LightTheme")

CreateResource(values, colors.xml,
<resources>
    <color name="actionbar">#00039be5</color>
   <color name="statusbar">#00006db3</color>
   <color name="textColorPrimary">#ff000000</color>
   <color name="navigationBar">#FFFFFFFF</color>
</resources>
)
CreateResource(values, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
        <item name="android:colorPrimary">@color/actionbar</item>
        <item name="android:colorPrimaryDark">@color/statusbar</item>
        <item name="android:textColorPrimary">@color/textColorPrimary</item>
        <item name="android:navigationBarColor">@color/navigationBar</item>
    </style>
</resources>
)

SetApplicationAttribute(android:largeHeap,"true")
CreateResourceFromFile(Macro, Core.NetworkClearText)

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)

'************ Firebase Base ************
CreateResourceFromFile("google-services", "google-services.json")
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
'AddPermission(android.permission.ACCESS_FINE_LOCATION)
'AddPermission(android.PERMISSION_ACCESS_COARSE_LOCATION)
AddManifestText( <permission android:name="${applicationId}.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />)
AddApplicationText(
<receiver
          android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
          android:enabled="true">
        <intent-filter>
          <action android:name="com.google.android.gms.measurement.UPLOAD"/>
        </intent-filter>
      </receiver>

      <service
          android:name="com.google.android.gms.measurement.AppMeasurementService"
          android:enabled="true"
          android:exported="false"/>   
    <provider
            android:authorities="${applicationId}.firebaseinitprovider"
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:exported="false"
            android:initOrder="100" />
      <receiver
          android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
          android:enabled="true">
        <intent-filter>
          <action android:name="com.google.android.gms.measurement.UPLOAD"/>
        </intent-filter>
      </receiver>

      <service
          android:name="com.google.android.gms.measurement.AppMeasurementService"
          android:enabled="true"
          android:exported="false"/>
    <receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>
       <receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
            android:exported="false" />

    
        <service
            android:name="com.google.firebase.iid.FirebaseInstanceIdService"
            android:exported="true">
            <intent-filter android:priority="-500">
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>
)
'************ Firebase Base (end) ************

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)
'************ Firebase Base (end) ************

'************ Firebase Auth ************
AddApplicationText(
   <activity android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar"
                  android:excludeFromRecents="true"
                  android:exported="false" />

        <service
            android:name="com.google.android.gms.auth.api.signin.RevocationBoundService"
            android:exported="true"
            android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" />
)
'************ Firebase Auth (end) ************
    
'************ Facebook Login ****************
CreateResource(values, facebook.xml, <resources>
    <string name="facebook_app_id">6354411307*****</string>
   </resources>)
 
AddApplicationText(
    <provider
            android:name="com.facebook.internal.FacebookInitProvider"
            android:authorities="${applicationId}.FacebookInitProvider"
            android:exported="false" />

        <receiver
            android:name="com.facebook.CurrentAccessTokenExpirationBroadcastReceiver"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.facebook.sdk.ACTION_CURRENT_ACCESS_TOKEN_CHANGED" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.facebook.AuthenticationTokenManager$CurrentAuthenticationTokenChangedBroadcastReceiver"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.facebook.sdk.ACTION_CURRENT_AUTHENTICATION_TOKEN_CHANGED" />
            </intent-filter>
        </receiver>
      
         <activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:theme="@style/com_facebook_activity_theme" />
        <activity android:name="com.facebook.CustomTabMainActivity" />
        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true"
             >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="cct.${applicationId}"
                    android:scheme="fbconnect" />
            </intent-filter>
        </activity>
)

'************ Facebook Login (end) **********
 
Upvote 0
Top