darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
193 stars 127 forks source link

FacebookActivity: Resources$NotFoundException #305

Open jimmyff opened 1 year ago

jimmyff commented 1 year ago

What version are you using?

4.4.0+1

What OS and version are you using to local deploy your application?

MacOS 12.4

What platforms are you seeing the problem on?

Android

pubspec.yaml

name: myapp
publish_to: none

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.1.0+36

environment:
  sdk: ">=2.12.0 <3.0.0"
  flutter: ^3.3.4

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  collection: ^1.16.0
  equatable: ^2.0.2
  redux: ^5.0.0
  redux_thunk: ^0.4.0
  redux_logging: any
  flutter_redux: ^0.10.0
  flutter_redux_navigation: ^0.7.0
  intl: any
  uuid: any
  package_info_plus: ^1.4.3+1

  page_transition: ^2.0.2
  carousel_slider: ^4.1.1

  logging: ^1.0.1

  path_provider: any # path_provider required for temp directory on upload
  image: ^3.0.2
  image_picker: any
  palette_generator: any
  image_cropper: ^2.0.3

  blurhash_dart: ^1.0.2
  shimmer: any

  photofilters: ^3.0.1
  exif: ^3.1.1
  reorderables: any
  in_app_purchase: ^3.0.2
  dotted_border: any
  flutter_image: ^4.1.0
  meta: ^1.1.8
  brand:
    path: ../os_brand
  os_core:
    path: ../os_core
  chroma:
    path: ../chroma

  pinch_zoom: ^1.0.0
  loading_indicator: ^3.1.0
  http: ^0.13.4
  open_store: ^0.3.1

  device_info: any
  lottie: ^1.3.0

  firebase_core: ^1.5.0
  cloud_firestore: ^3.1.8
  firebase_app_check: ^0.0.6+17
  firebase_auth: ^3.0.2
  firebase_storage: ^10.0.2
  firebase_analytics: ^9.0.4
  firebase_remote_config: ^2.0.0
  firebase_messaging: ^12.0.0
  firebase_crashlytics: ^2.8.7
  flutter_local_notifications: ^9.0.3
  audioplayers: ^1.0.0
  store_redirect: ^2.0.1
  flutter_markdown: ^0.6.9+1
  jovial_svg: ^1.1.5
  url_launcher: ^6.0.18
  csv: ^5.0.1

  package_info: any
  encrypt: any

  quiver: any
  cloud_firestore_platform_interface: any

  settings_ui: ^2.0.2
  ink_page_indicator: ^0.2.1
  transparent_image: ^2.0.0

  # For geo
  geolocator: ^9.0.1

  # Auth
  google_sign_in: ^5.0.4
  flutter_facebook_auth: ^4.0.1
  sign_in_with_apple: ^4.0.0

  crypto: ^3.0.1
  intl_phone_number_input: ^0.7.0+2
  pinput: ^2.2.4

  # Misc
  confetti: ^0.7.0
  material_design_icons_flutter: ^5.0.5955-rc.1
  badges: ^2.0.1
  animate_countdown_text: ^1.1.2
  animated_text_kit: ^4.2.2
  flutter_placeholder_textlines: ^1.1.2

Describe the Bug

Getting numerous crash repots via Crashalytics on Android production:

Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x7f0d0000
       at android.content.res.Resources.getValue(Resources.java:1351)
       at android.content.res.Resources.getDrawable(Resources.java:804)
       at android.content.Context.getDrawable(Context.java:458)
       at com.android.internal.widget.ToolbarWidgetWrapper.setIcon(ToolbarWidgetWrapper.java:322)
       at com.android.internal.widget.ActionBarOverlayLayout.setIcon(ActionBarOverlayLayout.java:737)
       at com.android.internal.policy.PhoneWindow.setDefaultIcon(PhoneWindow.java:1664)
       at android.app.Activity.initWindowDecorActionBar(Activity.java:2158)
       at android.app.Activity.getMenuInflater(Activity.java:3707)
       at android.app.Activity.onCreatePanelMenu(Activity.java:2853)
       at com.android.internal.policy.PhoneWindow.preparePanel(PhoneWindow.java:567)
       at com.android.internal.policy.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:939)
       at com.android.internal.policy.PhoneWindow$1.run(PhoneWindow.java:271)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5421)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I've been struggling to track down where this is coming from, however looking at the logs- the last screen before the crash is always FacebookActivity:

image

Could it be looking for an icon/logo that doesn't exist in my app and thats causing the crash?

Expected Behavior

No crashes

To Reproduce

Hard to say

Relevant log output

No response

flutter doctor -v

[✓] Flutter (Channel stable, 3.3.4, on macOS 12.4
    21F79 darwin-arm, locale en-GB)
    • Flutter version 3.3.4 on channel stable at
      /Users/jimmyff/sdks/flutter
    • Upstream repository
      https://github.com/flutter/flutter.git
    • Framework revision eb6d86ee27 (5 weeks ago),
      2022-10-04 22:31:45 -0700
    • Engine revision c08d7d5efc
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android
    devices (Android SDK version 33.0.0)
    • Android SDK at
      /Users/jimmyff/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/ja
      va
    • Java version OpenJDK Runtime Environment
      (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode
    13.4.1)
    • Xcode at
      /Applications/Xcode.app/Contents/Developer
    • Build 13F100
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google
      Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android
      Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨
      https://plugins.jetbrains.com/plugin/9212-fl
      utter
    • Dart plugin can be installed from:
      🔨
      https://plugins.jetbrains.com/plugin/6351-da
      rt
    • Java version OpenJDK Runtime Environment
      (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.73.0)
    • VS Code at /Applications/Visual Studio
      Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (4 available)
    • Pixel 5 (mobile)            • 09021FDD40027X
      • android-arm64  • Android 13 (API 33)
    • sdk gphone64 arm64 (mobile) • emulator-5554
      • android-arm64  • Android 13 (API 33)
      (emulator)
    • macOS (desktop)             • macos
      • darwin-arm64   • macOS 12.4 21F79
      darwin-arm
    • Chrome (web)                • chrome
      • web-javascript • Google Chrome
      107.0.5304.87

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
jimmyff@jimmys-mbp-5 internal %

Info.plist (iOS)

No response

Podfile (iOS)

No response

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myapp.app">
  <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->

  <!-- android:allowBackup="false" 
            android:fullBackupContent="false" added by jimmy to mitigate this
        issue with secure storage:
        https://github.com/mogol/flutter_secure_storage/issues/13#issuecomment-421083742
        -->

  <!--  Added by Jimmy for geolocation: 
https://pub.dev/packages/geolocation
-->
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="com.android.vending.BILLING" />

  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

  <!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> -->

  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> -->

  <application android:name="${applicationName}" android:label="My app" android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:fullBackupContent="@xml/backup_rules">

    <!-- <meta-data
    android:name="com.google.firebase.messaging.default_notification_channel_id"
    android:value="channel_id_app" /> -->

    <!-- Added by Jimmy - not sure if these ar eint he right area... -->
    <!-- Set custom default icon. This is used when no icon is set for incoming notification messages.
     See README(https://goo.gl/l4GJaQ) for more. was @drawable/ic_stat_ic_notification -->
    <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_stat_ic_notification" />
    <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
 notification message. See README(https://goo.gl/6BKBk7) for more. -->
    <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/colorAccent" />

    <!-- Added by jimmy for facebook authentication -->
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
    <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token" />

    <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
      <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
      <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
      <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->

      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>

      <!-- FCM: https://pub.dev/packages/firebase_messaging -->
      <intent-filter>
        <action android:name="FLUTTER_NOTIFICATION_CLICK" />
        <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>

    </activity>
    <activity android:name="com.yalantis.ucrop.UCropActivity" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.Light.NoActionBar" />

    <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data android:name="flutterEmbedding" android:value="2" />

    <!-- Added by jimmy for facebook sign in -->
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />

    <activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" />
    <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:scheme="@string/fb_login_protocol_scheme" />
      </intent-filter>
    </activity>

  </application>
</manifest>

MainActivity.java

No response

MainActivity.kt

No response

index.html

No response

Info.plist (macOS)

No response

darwin-morocho commented 1 year ago

@jimmyff since the facebook native sdk 14.x the client token must be added in your AndroidManifest.xml and the next code is not needed any more

 <activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" />
    <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:scheme="@string/fb_login_protocol_scheme" />
      </intent-filter>
    </activity>

check https://facebook.meedu.app/docs/4.x.x/android

jimmyff commented 1 year ago

Hey @darwin-morocho thanks for the reply. I will remove the code block you suggested, do you think that was causing all the crashes though?

I already include the client token:


    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
    <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token" />
`also you have this line duplicated 

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
darwin-morocho commented 1 year ago
`also you have this line duplicated 

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />

`also you have this line duplicated

jimmyff commented 1 year ago

Yes thanks, I removed that on too. I just am unsure if these changes will fix the Resources$NotFoundException crash

darwin-morocho commented 1 year ago

Yes thanks, I removed that on too. I just am unsure if these changes will fix the Resources$NotFoundException crash

The only way is running your project to be sure that the error has been gone

jimmyff commented 1 year ago

Will do a release today and report back

jimmyff commented 1 year ago

@darwin-morocho I'm still getting crash reports from FacebookActivity after removing the unnecessary AndroidManifest config. Do you have any other suggestions?

darwin-morocho commented 1 year ago

@darwin-morocho I'm still getting crash reports from FacebookActivity after removing the unnecessary AndroidManifest config. Do you have any other suggestions?

Try with the lastest version of this plugin. Also In your android/build.gradle check that you are not using jcenter instead mavenCentral. Check the example project

jimmyff commented 1 year ago

Still not managed to get to the bottom of this, however I keep seeing this in logcat, mentioning ZygoteInit which is the same as the crashalytics error as they use facebook sign in:


2022-11-14 16:34:30.288 3795-3795/? W/Resources: Drawable com.android.systemui:drawable/subroom_active_background has unresolved theme attributes! Consider using Resources.getDrawable(int, Theme) or Context.getDrawable(int).
    java.lang.RuntimeException
        at android.content.res.Resources.getDrawable(Resources.java:964)
        at com.android.systemui.qp.SubroomWifiSettingsView.updateView(SubroomWifiSettingsView.java:92)
        at com.android.systemui.qp.SubscreenWifiController$WifiSignalCallback.setWifiIndicators(SubscreenWifiController.java:144)
        at com.android.systemui.statusbar.policy.CallbackHandler.lambda$setWifiIndicators$0(CallbackHandler.java:134)
        at com.android.systemui.statusbar.policy.CallbackHandler.$r8$lambda$eo_aw2C3NKZ3xoTafvO2sST_bIs(Unknown Source:0)
        at com.android.systemui.statusbar.policy.CallbackHandler$$ExternalSyntheticLambda4.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8855)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Looks like this: https://stackoverflow.com/a/30267048/13051067