Reputation: 4813
I have just created a react-native library using react-native-create-library and imported it into my master react-native project.
There are some issues I'm having because (honestly) I lack the knowledge. The problem is that there are no errors (using logcat) and I don't know how I can debug the android part of my imported library.
Example
public class RNZappsCameraModule extends ReactContextBaseJavaModule
implements ActivityEventListener {
@ReactMethod
public void myJavascriptMethod() {
// I want a breakpoint here
// cameraIntent initialization happens here
try
{
currentActivity.startActivityForResult(cameraIntent, requestCode);
}
catch (ActivityNotFoundException e)
{
e.printStackTrace();
}
}
@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data)
{
// I want a breakpoint here
}
}
The camera intent starts fine, but I believe onActivityResult
is never hit.
I know I could log everything and read it, but that won't explain why the result is never returned to my app since there are no errors in the first place.
Google and the official RN documentation are not being my friend at the moment, so please put me on the right track.
Upvotes: 1
Views: 223
Reputation: 4813
Found it. No rocket science here. I don't know how I managed to do it in the end...
Anyheeew, to give this question a reasonable answer for passers-by... First off, you need a react-native (master) project in order to actually run your library in a react-native context.
So create it and import your library. The easiest way to do this is by pushing your library into a git repository and adding your library in the package.json of you master project like this:
"react-native-your-package": "git+https://your-git-url-here",
Now install it: npm install react-native-your-package
In order to debug your library:
Upvotes: 1