Skip to content

Commit

Permalink
Initial Android implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rotemmiz committed Jun 29, 2016
1 parent 53443de commit a3433b5
Show file tree
Hide file tree
Showing 13 changed files with 733 additions and 16 deletions.
195 changes: 191 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,186 @@
node_modules/


.npmignore


#################
# from .gitignore:
################


############
# Node
############
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

################
# JetBrains
################
.idea

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties


############
# iOS
############
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
ios/build/
ios/DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
ios/xcuserdata/

## Other
*.moved-aside
*.xcuserstate

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
ios/Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/screenshots


############
# Android
############
# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
android/bin/
android/gen/
android/out/

# Gradle files
android/.gradle/
android/build/
android/*/build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
android/proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
android/.navigation/

# Android Studio captures folder
android/captures/

# Intellij
*.iml

# Keystore files
*.jks

##################
# React-Native
##################
# OSX
#
.DS_Store
Expand Down Expand Up @@ -25,13 +208,17 @@ project.xcworkspace
# Android/IJ
#
.idea
.gradle
local.properties
android/.idea
android/.gradle
android/local.properties

# node.js
#
node_modules/
npm-debug.log

.idea/
node_modules/
# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore
81 changes: 70 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ More to come!

## Installation

### 1.Install react-native-newrelic:
### Install react-native-newrelic

```javascript
```bash
npm install react-native-newrelic --save
```

### 2. Install New RelicAgent in your project as a pod.
## iOS
#### 1. Install New RelicAgent in your project as a pod
In the Podfile for your project, add the following line:
`pod 'NewRelicAgent'`
Make sure Xcode is closed and run: `pod install`

### 3. Add the project to Xcode
#### 2. Add the project to Xcode
In the project navigator:
- Right click Libraries
- Add Files to [your project's name]
Expand All @@ -31,10 +31,10 @@ In the project navigator, select your project.
- Add the libRNDNewRelic.a to your project's Build Phases ➜ Link Binary With Libraries
- Click .xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic').

### 4. In your AppDelegate.m
#### 3. In your AppDelegate.m
Add the following:

```
``` objective-c
-(void)setupNewRelic{
NSString* token;
if(isDebug) {
Expand All @@ -47,26 +47,85 @@ Add the following:
```

And add the following line to the top of your didFinishLaunchingWithOptions function:
```

``` objective-c
[self setupNewRelic];
```

### 5. Add a prefix header to your iOS project
#### 4. Add a prefix header to your iOS project

Add a `PrefixHeader.pch` file as explained [here](https://docs.newrelic.com/docs/mobile-monitoring/mobile-monitoring-installation/ios/adding-prefix-header-ios-project)
Your file should look like this:
```

``` objective-c
#ifdef __OBJC__

#import <NewRelicAgent/NewRelic.h>

#endif
```

## Android (gradle only)

#### 1. Add NewRelic agent to your Android project

**[This link](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/install-configure/installing-android-apps-gradle-android-studio) describes how to add the original NewRelic agent to your project. This guide only requires a part of the original steps (some of the steps are already integrated in `react-native-newrelic`:**

Extend `Application.java` and override the following method:

``` java
public void onCreate() {
super.onCreate();
NewRelic.withApplicationToken("yourApplicationToken").start(this);
}
```

Create `newrelic.properties` in your root android dir:

```
com.newrelic.application_token= yourApplicationToken
```

> Get your application token from newrelic.com


#### 2. Add the `react-native-newrelic` module to your Android project

In `settings.gradle`:

``` gradle
include ':react-native-newrelic'
project(':react-native-newrelic').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-newrelic/android')
```

In your app level `build.gradle`:

``` gradle
dependencies {
...
compile project(":react-native-newrelic")
compile fileTree(dir: "node_modules/react-native-newrelic/android/libs", include: ["*.jar"])
...
}
```

Add `new RNNewRelicPackage()` to your list of packages in `getPackages()` in `MainActivity.java` :

``` java
@Override
public List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(... new RNNewRelicPackage());
}
```


## Configuration

Add the following to your app root (e.g. `app.ios.js` ):
```

```javascript
import {default as newRelic} from 'react-native-newrelic';
newRelic.init({
overrideConsole: true,
Expand Down
38 changes: 38 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apply plugin: 'com.android.library'
apply plugin: 'newrelic'

buildscript {
repositories {
mavenCentral()
jcenter()
maven {
// All of React Native (JS, Android binaries) is installed from npm
url "$rootDir/node_modules/react-native/android"
}
}
dependencies {
classpath 'com.newrelic.agent.android:agent-gradle-plugin:5.6.+'
}
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.newrelic.agent.android:android-agent:5.6.+'
compile 'com.facebook.react:react-native:+' //from node_modules
}
16 changes: 16 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Project-wide Gradle settings.
#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Wed Jun 29 09:00:55 IDT 2016
android.useDeprecatedNdk=true
Binary file added android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit a3433b5

Please sign in to comment.