Skip to content

Commit 7970b93

Browse files
author
Mihail Slavchev
committed
merge with master
2 parents 5a3c0ec + 718c5a5 commit 7970b93

86 files changed

Lines changed: 3382 additions & 7704 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,68 @@
11
env:
2-
global:
3-
- NDK_VERSION=r10e
2+
global:
3+
- NDK_VERSION=r10e
4+
- DATE=$(date +%Y-%m-%d)
5+
- PACKAGE_VERSION=$DATE-$TRAVIS_BUILD_NUMBER
6+
- ANDROID_VERSION=19
7+
- ANDROID_SUPPORT_VERSION=19.0.0
8+
- PACKAGE_NAME=tns-android
49
sudo: false
5-
language:
6-
android
10+
language: android
711
jdk:
8-
- oraclejdk8
12+
- oraclejdk8
913
git:
10-
submodules: false
14+
submodules: false
1115
android:
12-
components:
13-
- platform-tools
14-
- tools
15-
16-
- build-tools-22.0.1
17-
- android-22
18-
19-
- extra-android-support
20-
- extra-android-m2repository
21-
22-
- sys-img-x86_64-android-22
16+
components:
17+
- platform-tools
18+
- tools
19+
- build-tools-22.0.1
20+
- android-19
21+
- extra-android-support
22+
- extra-android-m2repository
23+
- sys-img-armeabi-v7a-android-19
24+
before_cache:
25+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
26+
cache:
27+
directories:
28+
- "$HOME/.gradle/caches/"
29+
- "$HOME/.gradle/wrapper/"
2330
before_install:
24-
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
25-
- git submodule update --init --recursive
26-
- wget http://dl.google.com/android/ndk/android-ndk-$NDK_VERSION-linux-x86_64.bin
27-
- chmod +x android-ndk-$NDK_VERSION-linux-x86_64.bin
28-
- ./android-ndk-$NDK_VERSION-linux-x86_64.bin | egrep -v ^Extracting
29-
- export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
30-
- export PATH=${PATH}:${ANDROID_NDK_HOME}
31-
31+
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
32+
- git submodule update --init --recursive
33+
- wget http://dl.google.com/android/ndk/android-ndk-$NDK_VERSION-linux-x86_64.bin
34+
- chmod +x android-ndk-$NDK_VERSION-linux-x86_64.bin
35+
- "./android-ndk-$NDK_VERSION-linux-x86_64.bin | egrep -v ^Extracting"
36+
- export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
37+
- export PATH=${PATH}:${ANDROID_NDK_HOME}
38+
before_script:
39+
- echo no | android create avd --force -n Arm19 -t android-19 -b armeabi-v7a -c 12M
40+
- emulator -avd Arm19 -no-skin -no-audio -no-window &
41+
- android-wait-for-emulator
3242
script:
33-
- gradle packar -PPACKAGE_VERSION=5.5.5
34-
43+
- "./gradlew packar -i -PPACKAGE_VERSION=$PACKAGE_VERSION -PcompileSdk=android-$ANDROID_VERSION
44+
-PsupportVersion=$ANDROID_SUPPORT_VERSION --stacktrace"
45+
- "./gradlew runtest -PenableTest -PcompileSdk=android-$ANDROID_VERSION -PsupportVersion=$ANDROID_SUPPORT_VERSION
46+
-PtargetSdk=$ANDROID_VERSION --stacktrace"
47+
before_deploy:
48+
- FULL_PACKAGE_VERSION=`sed -n 's/\s*"version":\s*"\([a-zA-Z0-9.\-]\+\)"/\1/p' dist/package.json`
49+
- mv dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz ../.deploymentpackage
50+
- mv .travis ../
51+
- cd ..
52+
- rm -rf android-runtime
53+
- tar -zxvf .deploymentpackage
54+
- mv package android-runtime
55+
- cd android-runtime
56+
- rm ../.deploymentpackage
57+
- nvm install 4.2.6
58+
- nvm use 4.2.6
59+
- mv ../.travis ./
60+
- node ./.travis/add-publishConfig.js next
61+
deploy:
62+
provider: npm
63+
email: nativescript@telerik.com
64+
on:
65+
branch: master
66+
skip_cleanup: true
67+
api_key:
68+
secure: aFJZR8VIbFAlXfFx5G2AveSgpGjr40prghvw8m06X0yvmUQlucwHVyq+Ov0ZD94br8d7OUOPbUzh+p9N/+oXLAXOj3DbQmJaCc+fk/e+avHu1BRy3fg295P9BQau1Abu+2ZO7tUbg5zAqJqhbEgjXsr9B5gxl+vwh4lbDhCPCwo=

.travis/add-publishConfig.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env node
2+
3+
var fsModule = require('fs');
4+
5+
//Adds a publishConfig section to the package.json file
6+
// and sets a tag to it
7+
8+
var path = './package.json';
9+
var fileOptions = {encoding: "utf-8"};
10+
var content = fsModule.readFileSync(path, fileOptions);
11+
12+
var tag = process.argv[2];
13+
if (!tag) {
14+
console.log('Please pass the tag name as an argument!');
15+
process.exit(1);
16+
}
17+
18+
var packageDef = JSON.parse(content);
19+
if (!packageDef.publishConfig) {
20+
packageDef.publishConfig = {};
21+
}
22+
packageDef.publishConfig.tag = tag;
23+
24+
var newContent = JSON.stringify(packageDef, null, ' ');
25+
fsModule.writeFileSync(path, newContent, fileOptions);

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
1.6.0
2+
==
3+
4+
## What's New
5+
6+
- [Build common test infrastructure for Android and iOS](https://github.com/NativeScript/android-runtime/issues/68)
7+
- [New syntax for Java arrays](https://github.com/NativeScript/android-runtime/issues/70)
8+
- [Improved debugger](https://github.com/NativeScript/android-runtime/issues/112)
9+
- [Log in the debugger console](https://github.com/NativeScript/android-runtime/issues/145)
10+
- [Update documentation](https://github.com/NativeScript/android-runtime/issues/290)
11+
- [Provide support for ARMv8a](https://github.com/NativeScript/android-runtime/issues/297)
12+
- [Imroved exception handling](https://github.com/NativeScript/android-runtime/issues/300)
13+
- Gradle script improvements
14+
15+
## Bug Fixes
16+
17+
- [Fix app crash during debugging (#270)](https://github.com/NativeScript/android-runtime/issues/270)
18+
- [Fix app hang during array marshalling](https://github.com/NativeScript/android-runtime/issues/320)
19+
- [Fix incorrect module resolution](https://github.com/NativeScript/android-runtime/issues/334)
20+
- [Fix app crash during debugging (#338)](https://github.com/NativeScript/android-runtime/issues/338)
21+
122
1.5.1
223
==
324

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/*
23
* Compiles binding generator
34
* to run: "gradle build"
@@ -6,14 +7,21 @@
67
*/
78
apply plugin: "java"
89

10+
def compiteCompileSdkVersion () {
11+
if(project.hasProperty("compileSdk")) {
12+
return compileSdk
13+
}
14+
return "android-22"
15+
}
16+
917
//workaround because there is a problem when the binding generator is compiled with java 1.7/1.8
1018
sourceCompatibility = 1.6
1119
targetCompatibility = 1.6
1220

1321
def pathToAndroidSdkPlatforms = "$System.env.ANDROID_HOME" + "/platforms"
1422

1523
dependencies {
16-
compile files(pathToAndroidSdkPlatforms + "/android-22/android.jar")
24+
compile files(pathToAndroidSdkPlatforms + "/" + compiteCompileSdkVersion() + "/android.jar")
1725
}
1826

1927
sourceSets {
@@ -24,7 +32,4 @@ sourceSets {
2432
}
2533
def isOutClassesDirSet = project.hasProperty("outClassesDir")
2634
main.output.classesDir = isOutClassesDirSet ? outClassesDir : "$rootDir/build/classesss"
27-
}
28-
29-
30-
35+
}

binding-generator/README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,40 @@
11
# android-binding-generator
2-
Contains the source of the binding generator tool for the NativeScript's Android Runtime.
2+
3+
This project is used in the [NativeScript runtime for Android](https://github.com/NativeScript/android-runtime) to generate Java subclasses at runtime. Supppose you have the following Java class
4+
5+
```Java
6+
package com.example;
7+
8+
public class MyClass {
9+
public int add(int x, int y) {
10+
return x + y;
11+
}
12+
}
13+
```
14+
15+
In NativeScript, you can inherit from `MyClass` using the following syntax:
16+
17+
```JavaScript
18+
var MyNewClass = com.example.MyClass.extend({
19+
add: function(x, y) {
20+
return x * y;
21+
}
22+
})
23+
24+
var obj = new MyNewClass();
25+
```
26+
27+
Using `extend` function will create a new Java class that looks roughly as follows
28+
```Java
29+
package <some auto-generated package name>;
30+
31+
public <some auto-generated class name> extends com.example.MyClass {
32+
public int add(int x, int y) {
33+
java.lang.Object[] params = new Object[2];
34+
params[0] = x;
35+
params[1] = y;
36+
return (int)com.tns.Platform.callJSMethod(this, "add", int.class, params);
37+
}
38+
}
39+
```
40+
The binding generator uses [ASMDEX library](http://asm.ow2.org/asmdex-index.html) to create the class above and to produce the corresponding `*.dex` file.

build.gradle

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,24 @@ task deleteCommitFile (type: Delete) {
179179
task generateRuntime (type: Exec) {
180180
doFirst{
181181
workingDir "$rootDir/src"
182-
182+
def passParams = new LinkedList<String>()
183+
passParams.addAll(envVars);
183184
//command gradlew buildar -PpackageVersion=[from_package.json] -PgitCommitVersion=[from_some_sys_variable]
184185
if(isWinOs) {
185-
envVars.addFirst("-PgitCommitVersion=${arVersion}");
186-
envVars.addFirst("-PpackageVersion=${pVersion}");
187-
envVars.addFirst("buildar");
188-
envVars.addFirst("gradlew");
189-
envVars.addFirst("/c");
190-
envVars.addFirst("cmd");
191-
commandLine envVars.toArray()
186+
passParams.addFirst("-PgitCommitVersion=${arVersion}");
187+
passParams.addFirst("-PpackageVersion=${pVersion}");
188+
passParams.addFirst("buildar");
189+
passParams.addFirst("gradlew");
190+
passParams.addFirst("/c");
191+
passParams.addFirst("cmd");
192+
commandLine passParams.toArray()
192193
}
193194
else {
194-
envVars.addFirst("-PgitCommitVersion=${arVersion}");
195-
envVars.addFirst("-PpackageVersion=${pVersion}");
196-
envVars.addFirst("buildar");
197-
envVars.addFirst("./gradlew");
198-
commandLine envVars.toArray();
195+
passParams.addFirst("-PgitCommitVersion=${arVersion}");
196+
passParams.addFirst("-PpackageVersion=${pVersion}");
197+
passParams.addFirst("buildar");
198+
passParams.addFirst("./gradlew");
199+
commandLine passParams.toArray();
199200
}
200201
}
201202
}
@@ -288,16 +289,23 @@ task packar {
288289
dependsOn packFramework
289290
}
290291

291-
292-
293-
294-
295-
296-
297-
298-
299-
300-
301-
302-
303-
292+
task runTest(type: Exec) {
293+
if(project.hasProperty("enableTest")) {
294+
workingDir "$rootDir/test-app"
295+
296+
def passParams = new LinkedList<String>()
297+
passParams.addAll(envVars);
298+
if(isWinOs) {
299+
passParams.addFirst("runtest");
300+
passParams.addFirst("gradlew");
301+
passParams.addFirst("/c");
302+
passParams.addFirst("cmd");
303+
commandLine passParams.toArray();
304+
}
305+
else {
306+
passParams.addFirst("runtest");
307+
passParams.addFirst("./gradlew");
308+
commandLine passParams.toArray();
309+
}
310+
}
311+
}

build/project-template-gradle/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ buildscript {
2323
jcenter()
2424
}
2525

26-
dependencies {
27-
classpath "com.android.tools.build:gradle:1.3.1"
28-
}
26+
dependencies {
27+
classpath "com.android.tools.build:gradle:1.5.0"
28+
}
2929
}
3030

3131
apply plugin: "com.android.application"
@@ -151,7 +151,7 @@ repositories {
151151
}
152152

153153
dependencies {
154-
def suppotVer = "22.2.0";
154+
def suppotVer = "23.2.0";
155155
if(project.hasProperty("supportVersion")) {
156156
suppotVer = supportVersion
157157
}
@@ -163,7 +163,7 @@ dependencies {
163163
compile fileTree(dir: "libs", include: ["**/*.jar"])
164164

165165
// take all jars within the node_modules dir
166-
compile fileTree(dir: nodeModulesDir, include: ["**/*.jar"])
166+
compile fileTree(dir: nodeModulesDir, include: ["**/platforms/android/**/*.jar"], exclude: '**/.bin/**')
167167

168168
// take all jars within the lib/Android dir
169169
compile fileTree(dir: libDir, include: ["**/*.jar"])
@@ -207,7 +207,7 @@ task pluginExtend {
207207
// we need to copy all dependencies into a flat dir, as pointed by the repositories configurations at the top
208208
task copyAarDependencies (type: Copy) {
209209
println "$configStage copyAarDependencies"
210-
from fileTree(dir: nodeModulesDir, include: ["**/*.aar"]).files
210+
from fileTree(dir: nodeModulesDir, include: ["**/*.aar"], exclude: '**/.bin/**').files
211211
into "libs/aar"
212212
}
213213

@@ -449,4 +449,4 @@ task buildapk {
449449
}
450450

451451
dependsOn deleteExplodedAarFolder
452-
}
452+
}

build/project-template-gradle/src/main/AndroidManifest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
android:minSdkVersion="17"
1515
android:targetSdkVersion="__APILEVEL__"/>
1616

17-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
18-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
1917
<uses-permission android:name="android.permission.INTERNET"/>
2018

2119
<application

0 commit comments

Comments
 (0)