Skip to content
This repository has been archived by the owner on Oct 12, 2018. It is now read-only.

'initWithOptions' of undefined #24

Open
damathryx opened this issue Nov 22, 2016 · 6 comments
Open

'initWithOptions' of undefined #24

damathryx opened this issue Nov 22, 2016 · 6 comments

Comments

@damathryx
Copy link

damathryx commented Nov 22, 2016

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
Copy link

eddanger commented Dec 7, 2016

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
Copy link

bakhansen commented Dec 7, 2016

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')
  1. In android/app/build.gradle add line in dependencies:
dependencies {
    compile project(':aws-sdk-react-native-core')
    ...
}
  1. In android/app/src/main/java/com/"your app name"/MainApplication.java
  • Add import:
    import com.amazonaws.reactnative.core.AWSRNCorePackage;

  • Add line:

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          ...,
          new AWSRNCorePackage() // add this line
      );
    }
  1. Run project:
    $ react-native run-android

Post which may be overlapping:
#4

@mnichols
Copy link

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
Copy link

alexmngn commented Jan 9, 2017

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

screen shot 2017-01-09 at 17 45 34

@mnichols
Copy link

mnichols commented Jan 9, 2017

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

@b-asaf
Copy link

b-asaf commented Jun 12, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants