Unknown directive "model" when setting up AWS Amplify GraphQL in Android - android

I've been trying to set up GraphQL for my android kotlin project with AWS Amplify, but I am getting red warning for #model as well as AuthRule & allow in:
This is the example TODO GraphQL schema, but when I do edit the schema, the issue still occurs. I'm wondering if I am missing something else that I didn't see in the documentation?
When I hover over #model, I see a Unknown directive "model" error message.
I tried to uninstalling and installing again the amplify add api. The error continues, and after searching through online, I don't see any solutions that are recent that can help with this.

Related

Expo notifications can't call `getExpoPushTokenAsync()`

Am currently trying to setup notifications on my managed expo project
Expo version 47.0.0
Expo notifications version 0.17.0
Device: Samsung Galaxy s10
Android version 12
I am currently just trying to get the basic setup itself working and retrieve my devices push token. This should be done using Notifications.getExpoPushTokenAsync() as described here.
The Problem
My error is strange, when I call getExpoPushTokenAsync it does indeed get me the expo push token, however shortly after my app crashes with the following messages
ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[1], "../../../src/util").types.isPromise')
WARN [expo-notifications] Error encountered while updating server registration with latest device push token. [TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[5], "#ide/backoff").computeNextBackoffInterval')]
I have tried
re-installing node_modules and expo-notifications but still get the same.
I can definitely see the #ide/backoff package is installed in my node_modules.
I also followed these instructions to setup firebase in app, even though my understanding is that it should work out of the box in expo go app while devving.
One other interesting thing is that I can call Notifications.getDevicePushTokenAsync() fine with no error. But still get the same error if i pass that in to getExpoPushTokenAsync method after. At a surface level it seems like somehow the request out to expo services to get the expo push token is both passing and failing 🤷‍♂️
const devicePushTokenResponse = await Notifications.getDevicePushTokenAsync();
const expoPushTokenResponse = await Notifications.getExpoPushTokenAsync({
devicePushToken: devicePushTokenResponse,
}); // <--- Returns token & errors a few seconds later
Couldn't see any other posts with this error and expo-notifications, so would be keen to see if anyone else has ran into / fixed a similar issue recently
Cheers
Alright I figured it out, it was somewhat hinted at by this line
ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[1], "../../../src/util").types.isPromise')
And more specifically the fact that a node_modules dependency is referencing 3 levels up in the file system.
The solution
Turns out that for some reason my module resolver (defined in babel.config.js) was resolving my project's util folder instead of the packages util folder. I think this was compounded by my metro config making use of the inlineRequires functionality to improve performance (see more)
I am sure there is some actual config that could be updated to exclude node_modules from using inline requires (i did try use a blocklist to no avail), but as an interim, i was able to get it working fine by changing the path of my util folder to be #my-project/util so that it avoids future collisions.
Hope this helps anyone who runs into the same issue in the future :)

Failed to find code-generated model provider - AWS Amplify

I'm getting the below error:
Failed to find a code-generated model provider.
AWS amplify code which throwing this error:
Amplify.addPlugin(new AWSApiPlugin());
Amplify.addPlugin(new AWSDataStorePlugin());
Amplify.configure(context);
I am following the below tutorials:
https://docs.amplify.aws/start/getting-started/generate-model/q/integration/android
https://docs.amplify.aws/cli/graphql-transformer/overview
I have tried generating models and models get generated successfully but still while running the app I am getting above exception.
When you generate models, you should expect to find various code-generated files in your application project. One of them will be app/src/main/java/com/amplifyframework/datastore/generated/model/AmplifyModelProvider.java.
When you build your app, Android Studio will compile that java file into a class file, and include it into your binary.
At runtime, on the phone, the AWSDataStorePlugin() constructor will attempt to find that same AmplifyModelProvider by means of reflection.
I would verify that:
You do actually have the code-generated AmplifyModelProvider;
It is being built successfully;
It is not being stripped out by ProGuard/R8 minification.
If you're still not able to get it working, just use the one-argument version of the AWSDataStorePlugin(...) constructor, instead. That version allows you to explicitly specify the model provider, and does not use runtime reflection.
Amplify.addPlugin(AWSDataStorePlugin(AmplifyModelProvider.getInstance()))
Your datasource needs to be updated:
Try running modelGen, then amplifyPush tasks:
Category
Resource name
Operation
Provider plugin
Api
amplifyDatasource
Update
awscloudformation

How to fix a "java.io.IOException: unexpected end of stream on Connection" exception in HTTPClient on .NetStandard

I have been scratching my head with this one for a while. I'm building an Android app in Xamarin and I have a login POST request that mostly works, but will occasionally recieve this error. I notify the user and tell them to try again but I am still getting the error far too often and want to fix it so the app provides a smoother experience.
Here is the stack trace I have logged on App Center:
LoginProvider+d__1.MoveNext () C:\source\repos{MyApp}{MyApp}{MyApp}\Services\LoginProvider.cs:35
java.io.IOException: unexpected end of stream on Connection{testclarity.i-menzies.com:443, proxy=DIRECT# hostAddress=62.244.173.166 cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=http/1.1} (recycle count=0)
com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:210)
com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:905)
com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:789)
com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:443)
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:388)
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:501)
com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
Caused by: java.io.EOFException: \n not found: size=0 content=...
com.android.okhttp.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:200)
com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:191)
I am using .NETStandard 2.0, with Xamarin Forms 3.2.0.871581.
I have scoured most of Google and identified that this is an issue with various Android libraries, especially OkHttp (the same one mentioned in my stack trace). I've tried investigating the .NETStandard source on Github to identify the possible cause, but I find the project very difficult to navigate, especially as this problem seems to be Android specific. Any advice on finding the right source would be ideal.
Things I have tried based on suggestions from the internet:
Setting my connection header to closed.
Setting my transfer encoding
to chunked.
Swapping out the Android HttpClient implementation from
Android to Default in the Android project's properties.
These seem to be among the popular suggestions online, some of which work for people, some of which don't.
Another common suggestion is setting the OkHttp library's configuration to OkHTTP.setRetryOnConnectionFailure(true), which apparently fixes the problem for many people, as suggested here: https://github.com/square/okhttp/issues/1517#issuecomment-144069139.
Also, a similar bug seems to have been filed in Xamarin.Android here: https://bugzilla.xamarin.com/show_bug.cgi?id=41100. But this has been marked as fixed. I'm not sure whether this would feed into my Xamarin Forms project.
Does anyone know how I can fix this problem or how I can investigate further beyond what I've already tried?
After following the information in this link: https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/http-stack?tabs=macos
And changing my HTTPHandler to the native android handler:
The Xamarin.Android HttpClient configuration is in Project Options >
Android Options, then click the Advanced Options button.
These are the recommended settings for TLS 1.2 support:
Visual Studio Android Options
The one extra bit I missed was:
Projects must reference the System.Net.Http assembly.
Make sure your project references System.Net.Http otherwise it will still use OKHttp
You can just go the Android Project > Properties > AssemblyInfo.cs file.
Open the AssemblyInfo file and add the following line at the end:
[assembly: Application(UsesCleartextTraffic = true)]
This helped me solve my problem. I hope it helps you also
I was having the same issue and been tracing for this fix. My project reference
to System.Net.Http.
I was changing my HTTPHandler to the native android handler when I got this exception but getting kinda similar system exception when using a different HTTPHandler.
I tried a lot of suggestions and finally fixes the issue by using https in my base URL. Here's my reference: https://github.com/square/okhttp/issues/1517#issuecomment-560486265
IMO, the fix might be different in each case, so you might want to try other suggestions.

Unity Auth Error With Firebase

I implemented Firebase into a Unity app I am creating. There are two buttons that will run the two functions to create a new user and login an existing user. So far this functionality works on my PC, however whenever I try to deploy it to my android phone or Mac I end up getting the following error in the console.
DllNotFoundException: FirebaseCppApp-5.1.0
Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for SWIGExceptionHelper
Firebase.AppUtilPINVOKE..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.AppUtilPINVOKE
Firebase.AppUtil.SetLogFunction (Firebase.LogMessageDelegate arg0)
It appears there is a missing .dll file, however I cannot for the life of me find out how to include it within the project file. I also have double checked the package name and it is the exact same name as the one made for my Firebase project, the google-services JSON in the root of the project, and the Api compatibility level is set to .NET 2.0. On top of that I also uninstalled and reinstalled the app a few times. I also tried using the Play Services Resolver which didn't help much at all either.
Similar error here, only with Firebase Cloud Messaging. After tinkering around in a fashion similar to yours I concluded that it was caused by corruption during import of Firebase Package.
What worked for me:
Deleted each and every folder created while importing Firebase Package.
Reimported Firebase Package

Podio Android SDK item create API call error "Object not found"

I have a problem with the Podio SDK on Android in the following scenario:
I have uploaded an image to Podio from our server in a php script and returned the file_id to my Android app via http. The id seems to be valid, but when i try to create an item using this file_id for an image field value i get the following error messages:
E/Volley: [49051] BasicNetwork.performRequest: Unexpected response code 404 for https://api.podio.com/item/app/17418679
com.podio.sdk.ApiError: {"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http:\/\/api.podio.com\/item\/app\/17418679","query_string":"","method":"POST"},"error_description":"Object not found","error":"not_found"}
If i do not attach the image the item create call works fine
I used the newest version of the Podio Android SDK from Github (https://github.com/podio/podio-android) compiled using Android Studio 2.3 and build tools version 25.
I already found an error where the wrong app_id was used, but fixing that still left me with the same message.
This used to work only a few weeks ago, maybe there was change in the API? Do you have any tips on what else could cause this problem? I am using different client id / secret in the php script than in the app, could that be the reason?

Categories

Resources