Skip to content

feat: add new hybrid app #1301

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ yarn-debug.log
yarn-error.log
coverage/
.jest/cache/
.yarn

# OSX
.DS_Store
Expand Down Expand Up @@ -62,7 +63,8 @@ android/keystores/debug.keystore

# Bundle artifact
*.jsbundle
/examples/default/ios/main.jsbundle.map
*.bundle
main.jsbundle.map

# Vscode local history
.history/
Expand Down
4 changes: 4 additions & 0 deletions examples/hybrid/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
};
1 change: 1 addition & 0 deletions examples/hybrid/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
62 changes: 62 additions & 0 deletions examples/hybrid/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* eslint-disable react-native/no-inline-styles */
import { ReactNode, useEffect } from 'react';
import React from 'react';
import { Button, Image, SafeAreaView, Text } from 'react-native';
import Instabug, {
CrashReporting,
InvocationEvent,
LogLevel,
ReproStepsMode,
} from 'instabug-reactnative';

const throwHandled = () => {
try {
throw Error('This is a handled JS Crash');
} catch (err) {
if (err instanceof Error) {
CrashReporting.reportError(err);
}
}
};

const throwUnhandled = () => {
throw Error('This is an unhandled JS Crash');
};

const App: () => ReactNode = () => {
useEffect(() => {
Instabug.init({
token: 'deb1910a7342814af4e4c9210c786f35',
invocationEvents: [InvocationEvent.floatingButton],
debugLogsLevel: LogLevel.verbose,
});
CrashReporting.setNDKCrashesEnabled(true);
Instabug.setReproStepsConfig({
all: ReproStepsMode.enabled,
});
}, []);

return (
<SafeAreaView
style={{
minHeight: '100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}>
<Image
source={{
uri: 'https://reactnative.dev/img/tiny_logo.png',
height: 100,
width: 100,
}}
/>
<Text style={{ fontSize: 21, fontWeight: '700' }}>React Native App</Text>
<Button title="Handled Crash" onPress={throwHandled} />
<Button title="Unhandled Crash" onPress={throwUnhandled} />
</SafeAreaView>
);
};

export default App;
17 changes: 17 additions & 0 deletions examples/hybrid/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import App from '../App';

// Note: import explicitly to use the types shipped with jest.
import { it } from '@jest/globals';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
});
86 changes: 86 additions & 0 deletions examples/hybrid/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.facebook.react'

}

android {
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
}
}
namespace 'com.instabug.hybridsampleapp'
compileSdk 34

defaultConfig {
applicationId "com.instabug.hybridsampleapp"
minSdk 29
targetSdk 34
versionCode 1
versionName "1.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.8"
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
compose = true
buildConfig = true
}
}

dependencies {
// Use consistent versions
def composeBom = platform('androidx.compose:compose-bom:2023.10.00')
implementation composeBom
androidTestImplementation composeBom

// Compose dependencies
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.material3:material3"
implementation "androidx.compose.ui:ui-tooling-preview"
debugImplementation "androidx.compose.ui:ui-tooling"
implementation libs.androidx.appcompat
implementation libs.androidx.appcompat.resources
implementation libs.androidx.core.ktx.v1130
implementation libs.androidx.core
implementation libs.androidx.activity
implementation libs.androidx.transition
implementation libs.androidx.annotation.experimental
implementation "com.facebook.react:react-android"
implementation "com.facebook.react:hermes-android"
// Other dependencies...
}
configurations.all {
resolutionStrategy {
force "androidx.appcompat:appcompat:${rootProject.ext.androidXAppCompatVersion}"
force "androidx.appcompat:appcompat-resources:${rootProject.ext.androidXAppCompatVersion}"
force "androidx.core:core:${rootProject.ext.androidXCoreVersion}"
force "androidx.core:core-ktx:${rootProject.ext.androidXCoreVersion}"
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Binary file added examples/hybrid/android/app/debug.keystore
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading