amazon-archives / aws-sdk-react-native

AWS SDK for React Native (developer preview)
Apache License 2.0
631 stars 68 forks source link

'initWithOptions' of undefined #24

Open damathryx opened 7 years ago

damathryx commented 7 years ago

I'm getting this error on both iOS and Android screen shot 2016-11-22 at 1 57 30 pm

inside my contructor i have this screen shot 2016-11-22 at 1 59 09 pm

what seems to be the problem?

eddanger commented 7 years ago

I'm getting the same problem. It seems that the NativeModule for AWSCognitoCredentials isn't being registered correctly for use in the app. I can't figure out the setup quite yet but I suspect it has something to do with registering the AWS Mobile SDK and the platform specific code (.h, .m and .java) from the git repo with the project.

A complete step-by-step set up guide would be very helpful.

bakhansen commented 7 years ago

Edit: Maybe you can use (instead of the instructions below): react-native link - I just used this setting up some other module

I just reproduced the error by commenting out a line in Android native code: initwithoptions

I'm running with : Initial Release v0.0.1

What I had to do to fix it: In a react-native project

  1. In android/settings.gradle add lines:
    include ':aws-sdk-react-native-core'
    project(':aws-sdk-react-native-core').projectDir = new File(rootProject.projectDir, '../node_modules/aws-sdk-react-native-core/android')
  2. In android/app/build.gradle add line in dependencies:
    dependencies {
    compile project(':aws-sdk-react-native-core')
    ...
    }
  3. In android/app/src/main/java/com/"your app name"/MainApplication.java

Post which may be overlapping: https://github.com/awslabs/aws-sdk-react-native/issues/4

mnichols commented 7 years ago

When I called react-native link it didnt seem to link the Core product to my project so I followed the 'manual linking' instructions here to get past this.

So you could:

  1. npm install ../../path/to/aws-sdk-react-native-core-0.0.2.tgz
  2. open your project's .xcodeproj (or workspace)
  3. open the Core project at something like $(SRCROOT)/node_modules/aws-sdk-react-native-core/Core.xcodeproj
  4. drag that .xcodeproject to your project's Libraries dir
  5. select your project and expand to it's 'Build Phases' > 'Link Library with Libraries'
  6. drag the static lib from /Libraries/Core.xcodeproj/Products/libCore.a to the 'Link Library' listing you expanded
  7. Build

Since you can interact with the Core, AWSCognitoIdentity.js script there isnt a need to update your header paths for Cognito usage directly although the API inside there might cause me to do so.

alexmngn commented 7 years ago

@mnichols I tried those steps but I keep having the same error from Xcode:

screen shot 2017-01-09 at 17 45 34
mnichols commented 7 years ago

That looks like header search path issue in your app's iOS project

b-asaf commented 7 years ago

Hi, currently I am working on Android, But I am looking for a solution for iOS as well. regarding @mnichols solution - from where I get 'aws-sdk-react-native-core-0.0.2.tgz' to install in my project? when I try @bakhansen solution 'react-native run-android' command fail because it can't delete '[ProjectName]\android\app\build\generated\source\r\debug\android\support' folder

can you help, all I want is to download file from S3