nklhtv/jxcore-android-sdk


Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.NikolaBorislavovHristov:jxcore-android-sdk:v1.0.2'
	}
	dependencies {
		implementation("com.github.NikolaBorislavovHristov:jxcore-android-sdk:v1.0.2")
	}
	<dependency>
	    <groupId>com.github.NikolaBorislavovHristov</groupId>
	    <artifactId>jxcore-android-sdk</artifactId>
	    <version>v1.0.2</version>
	</dependency>

                            
    libraryDependencies += "com.github.NikolaBorislavovHristov" % "jxcore-android-sdk" % "v1.0.2"
        
        

                            
    :dependencies [[com.github.NikolaBorislavovHristov/jxcore-android-sdk "v1.0.2"]]
        
        

Readme


jxcore-android-sdk

FAQ

Start Node.js server on Android in a background service.

This project use jxcore v3.1.14 compiled with SpiderMonkey. If you want to use V8 instead replace the content of the jxcore-binaries directory with the compiled binaries.

Compiled JXCore binaries used from thaliproject/jxbuild

Example project

How to:

  1. Add the JitPack repository to your build file
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the JXCore SDK dependency
dependencies {
    implementation 'com.github.NikolaBorislavovHristov:jxcore-android-sdk:master-SNAPSHOT'
}
  1. Declare the service in the manifest file
<service android:name="io.jxcore.node.JXCoreService"
    android:enabled="true"
    android:permission="android.permission.INTERNET"
    android:exported="true"
/>
  1. Add server.js asset in the assets/www/jxcore directory
var http = require('http');
var port = 8082;
var server = http.createServer(function(request, response) {
    response.end('Hello Node.js Server!');
});

server.listen(port, function(err) {
    if (err) {
        console.error(err);
        return;
    }
    
    console.log('server is listening on ' + port);
});
  1. Start the jxcore service
final Intent startJXCoreIntent = new Intent(getApplicationContext(), JXCoreService.class);
startService(startJXCoreIntent);