Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform Exception Error when running app in release mode #34

Open
codesbyatif opened this issue Dec 8, 2021 · 13 comments
Open

Platform Exception Error when running app in release mode #34

codesbyatif opened this issue Dec 8, 2021 · 13 comments
Assignees
Labels
bug Something isn't working platform:android

Comments

@codesbyatif
Copy link

Steps to Reproduce

  1. When the login button is pressed in release mode the platform error occurs

Expected results: Successful Login

Actual results: E/flutter (27362): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(UnknownGetUserError, Unknown Error, 400, null)
E/flutter (27362): #0 Snapkit.currentUser (package:snapkit/snapkit.dart:138)
E/flutter (27362):
E/flutter (27362): #1 Snapkit.login (package:snapkit/snapkit.dart:57)
E/flutter (27362):
E/flutter (27362):**

Logs
  info • This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: HomeScreen.snapchatUser •
          lib/Screens/HomeScreen.dart:21:7 • must_be_immutable
   info • 'overflow' is deprecated and shouldn't be used. Use clipBehavior instead. See the migration guide in flutter.dev/go/clip-behavior. This feature was deprecated
          after v1.22.0-12.0.pre. • lib/Screens/HomeScreen.dart:501:59 • deprecated_member_use
   info • 'Overflow' is deprecated and shouldn't be used. Use clipBehavior instead. See the migration guide in flutter.dev/go/clip-behavior. This feature was deprecated
          after v1.22.0-12.0.pre. • lib/Screens/HomeScreen.dart:502:63 • deprecated_member_use
   info • Cancel instances of dart.async.StreamSubscription • lib/Screens/Mainscreen.dart:22:36 • cancel_subscriptions
   info • Unused import: 'package:path_provider/path_provider.dart' • lib/Screens/NewSnapScreen.dart:11:8 • unused_import
   info • This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: NewSnapScreen.snapchatUser
          • lib/Screens/NewSnapScreen.dart:17:7 • must_be_immutable
   info • 'overflow' is deprecated and shouldn't be used. Use clipBehavior instead. See the migration guide in flutter.dev/go/clip-behavior. This feature was deprecated
          after v1.22.0-12.0.pre. • lib/Screens/NewSnapScreen.dart:227:13 • deprecated_member_use
   info • 'Overflow' is deprecated and shouldn't be used. Use clipBehavior instead. See the migration guide in flutter.dev/go/clip-behavior. This feature was deprecated
          after v1.22.0-12.0.pre. • lib/Screens/NewSnapScreen.dart:227:23 • deprecated_member_use
   info • 'overflow' is deprecated and shouldn't be used. Use clipBehavior instead. See the migration guide in flutter.dev/go/clip-behavior. This feature was deprecated
          after v1.22.0-12.0.pre. • lib/Screens/NewSnapScreen.dart:419:31 • deprecated_member_use
   info • 'Overflow' is deprecated and shouldn't be used. Use clipBehavior instead. See the migration guide in flutter.dev/go/clip-behavior. This feature was deprecated
          after v1.22.0-12.0.pre. • lib/Screens/NewSnapScreen.dart:419:41 • deprecated_member_use
[✓] Flutter (Channel stable, 2.2.3-0.0.pre.2, on Mac OS X 10.15.7 19H1323 darwin-x64, locale en-PK)
    • Flutter version 2.2.3-0.0.pre.2 at /Users/Flash/Developer/flutter
    • Framework revision a794a412e1 (6 months ago), 2021-06-12 17:13:00 +0500
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/Flash/Library/Android/sdk
    • Platform android-31, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.1, Build version 12A7403
    • CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

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

[✓] Connected device (2 available)
    • Nokia 6 1 (mobile) • PL2GAMU841604032 • android-arm64  • Android 10 (API 29)
    • Chrome (web)       • chrome           • web-javascript • Google Chrome 96.0.4664.55

• No issues found!
@TimmyRB
Copy link
Owner

TimmyRB commented Dec 8, 2021

Are you using the example app or your own app?
Does the same error occur when using the Staging Client ID?
What platform & device are you running it on that causes this?
Please include your AndroidManifest.xml if this is happening on Android or your Info.plist if it happens on iOS

@TimmyRB TimmyRB self-assigned this Dec 8, 2021
@codesbyatif
Copy link
Author

codesbyatif commented Dec 8, 2021

it's working completely fine on debug and profile mode but giving error in release mode.
same error with my own project as well as example with both staging and production Client ID
Running it on Android 10
**My Android.manifest: **



    <meta-data
        android:name="com.snapchat.kit.sdk.redirectUrl"
        android:value="unknown://snapchat/oauth2" />

    <meta-data
        android:name="com.snapchat.kit.sdk.scopes"
        android:resource="@array/snap_connect_scopes" />

    <activity
        android:name="com.snapchat.kit.sdk.SnapKitActivity"
        android:launchMode="singleTask">

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <!-- Change this to match your redirect URL -->
            <data
                android:scheme="unknown"
                android:host="snapchat"
                android:path="/oauth2" />
        </intent-filter>
    </activity>
    <provider
       android:name="androidx.core.content.FileProvider"
       android:authorities="${applicationId}.fileprovider"
       android:exported="false"
       android:grantUriPermissions="true">
       <meta-data
           android:name="android.support.FILE_PROVIDER_PATHS"
           android:resource="@xml/file_paths" />
   </provider>
    <activity
        android:name=".MainActivity"
        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">
       
        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        
        <meta-data
          android:name="io.flutter.embedding.android.SplashScreenDrawable"
          android:resource="@drawable/launch_background"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <!-- 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" />
</application>
<queries>
    <package android:name="com.snapchat.android"/>
</queries>

@TimmyRB
Copy link
Owner

TimmyRB commented Dec 8, 2021

It looks like you're missing quite a few things in your AndroidManifest.xml, make sure you followed the instructions on the Wiki

@codesbyatif
Copy link
Author

Example project is giving the same error and i have gone through android.manifest multiple times, please if you can let me know what i am missing there.

@TimmyRB
Copy link
Owner

TimmyRB commented Dec 9, 2021

I was able to reproduce this error, as far as I can tell the error occurs because you're using the Staging key from the Snapchat Developer Portal in a release build instead of the Production key which requires that your app is approved by Snapchat before it can be used, however I will do some more testing soon to make sure. If you're able to get your app approved by Snapchat, try switching to the Production key and let me know if your release build starts working once making the switch!

@TimmyRB TimmyRB added bug Something isn't working platform:android labels Dec 9, 2021
@codesbyatif
Copy link
Author

codesbyatif commented Dec 9, 2021

The app is approved from snapkit developer portal and I am using the production client id here with staging and production client id and it's working fine in debug and profile mode.
Screenshot 2021-12-09 at 11 52 45 AM
I am using this production key in my android.manifest file

@TimmyRB
Copy link
Owner

TimmyRB commented Dec 9, 2021

Where are you using the Production Key in your AndroidManifest.xml, the line to include it isn't in the code you provided as the top part of your AndroidManifest.xml is missing?

@codesbyatif
Copy link
Author

codesbyatif commented Dec 9, 2021

My bad, it is there but I forgot to copy that
here is my androidmanifest.xml

<application
    android:label="Unknown"
    android:usesCleartextTraffic="true"
    android:icon="@mipmap/ic_launcher">
    <meta-data
    android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/logo" />
    <meta-data
        android:name="com.snapchat.kit.sdk.clientId"
        android:value="***************"/>
<meta-data
    android:name="com.snapchat.kit.sdk.redirectUrl"
    android:value="unknown://snapchat/oauth2" />

<meta-data
    android:name="com.snapchat.kit.sdk.scopes"
    android:resource="@array/snap_connect_scopes" />

<activity
    android:name="com.snapchat.kit.sdk.SnapKitActivity"
    android:launchMode="singleTask">

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <!-- Change this to match your redirect URL -->
        <data
            android:scheme="unknown"
            android:host="snapchat"
            android:path="/oauth2" />
    </intent-filter>
</activity>
<provider
   android:name="androidx.core.content.FileProvider"
   android:authorities="${applicationId}.fileprovider"
   android:exported="false"
   android:grantUriPermissions="true">
   <meta-data
       android:name="android.support.FILE_PROVIDER_PATHS"
       android:resource="@xml/file_paths" />
    <meta-data
      android:name="io.flutter.embedding.android.NormalTheme"
      android:resource="@style/NormalTheme"
      />
    
    <meta-data
      android:name="io.flutter.embedding.android.SplashScreenDrawable"
      android:resource="@drawable/launch_background"
      />
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>
<!-- 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" />

@dammalani
Copy link

Did anyone find the solution for this? I have the same issue, working fine on debug mode, and not working on release apk. I am using production client Id.

@zeshanmusaw
Copy link

Did anyone find the solution for this? I have the same issue, working fine on debug mode, and not working on release apk. I am using production client Id. Please any one have solution for this ,
Thanks

@markszente
Copy link

Hey @atif2148, did you manage to solve this? Also, how long did it take to get your Snap Kit app approved? Thanks.

@markszente
Copy link

Hello @atif2148 @dammalani @zeshanmusaw, as of Snap Kit v1.13.0, SnapLogin#fetchUserData(), which this plugin uses, has been deprecated, which may or may not be the cause of this issue. There is a new fetchUserData() in the SnapLoginApi interface.
I've forked this repo, upgraded to v1.13.1 and re-implemented the getUser logic. For now, I have no way of checking whether this works in release mode, because Snapchat has yet to approve my app...

Could you tell me how much time did the the review take in your cases? Anyway, here is the forked repo, feel free to try it. I would be willing to make a PR if it does work, but I converted the android platform-specific code to Kotlin because I absolutely abhor Java. I'm not sure whether the author is okay with this change.

@ramyajaganathan
Copy link

I also have same issue . Have anyone solved the issue . How? please share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform:android
Projects
None yet
Development

No branches or pull requests

6 participants