Update build scons for notificaiton android sample.
authorKIM JungYong <jyong2.kim@samsung.com>
Wed, 5 Oct 2016 12:06:52 +0000 (21:06 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 10 Oct 2016 01:05:55 +0000 (01:05 +0000)
When building notification service on android,
was built just aar file but sample apk.
In this patch building android will be built aar file and sample apk.

Conflicts:
        service/notification/examples/android/NotiConsumerExample/app/build.gradle

Change-Id: I32b9e06600e9063bc8115cd7302c73c938d14e8f
Signed-off-by: KIM JungYong <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/12975
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
13 files changed:
service/notification/SConscript
service/notification/cpp-wrapper/SConscript
service/notification/examples/android/NotiConsumerExample/SConscript [new file with mode: 0644]
service/notification/examples/android/NotiConsumerExample/app/build.gradle
service/notification/examples/android/NotiConsumerExample/app/src/main/java/com/sec/noticonsumerexample/MainActivity.java
service/notification/examples/android/NotiConsumerExample/app/src/main/res/values/styles.xml
service/notification/examples/android/NotiConsumerExample/build.gradle
service/notification/examples/android/NotiProviderExample/SConscript [new file with mode: 0644]
service/notification/examples/android/NotiProviderExample/app/build.gradle [changed mode: 0644->0755]
service/notification/examples/android/NotiProviderExample/app/src/main/java/com/sec/notiproviderexample/MainActivity.java
service/notification/examples/android/NotiProviderExample/app/src/main/res/values/styles.xml
service/notification/examples/android/NotiProviderExample/build.gradle
service/notification/examples/android/SConscript [new file with mode: 0644]

index 24cc8b7..c4390a0 100755 (executable)
@@ -121,11 +121,11 @@ notification_env.UserInstallTargetHeader('include/NSConsumerInterface.h',\
 if target_os == 'linux':
     SConscript('unittest/SConscript')
 
-# Go to build sample apps
-SConscript('examples/SConscript')
-
 # Go to build c++ wrapper
 SConscript('cpp-wrapper/SConscript')
 
 if target_os == 'android':
     SConscript('android/SConscript')
+
+# Go to build sample apps
+SConscript('examples/SConscript')
\ No newline at end of file
index b9005a0..fa553bd 100755 (executable)
@@ -28,5 +28,6 @@ SConscript('provider/SConscript')
 SConscript('consumer/SConscript')
 
 # Go to build sample apps using wrapper
-SConscript('examples/linux/SConscript')
+if target_os == 'linux':
+    SConscript('examples/linux/SConscript')
 
diff --git a/service/notification/examples/android/NotiConsumerExample/SConscript b/service/notification/examples/android/NotiConsumerExample/SConscript
new file mode 100644 (file)
index 0000000..e78f569
--- /dev/null
@@ -0,0 +1,83 @@
+#//******************************************************************
+#//
+#// Copyright 2016 Samsung Electronics All Rights Reserved.
+#//
+#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#//
+#// Licensed under the Apache License, Version 2.0 (the "License");
+#// you may not use this file except in compliance with the License.
+#// You may obtain a copy of the License at
+#//
+#//      http://www.apache.org/licenses/LICENSE-2.0
+#//
+#// Unless required by applicable law or agreed to in writing, software
+#// distributed under the License is distributed on an "AS IS" BASIS,
+#// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#// See the License for the specific language governing permissions and
+#// limitations under the License.
+#//
+#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+import os
+import platform
+Import('env')
+
+android_home = env.get('ANDROID_HOME')
+
+ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')
+if env.get('RELEASE'):
+       ANDROID_RELEASE="release"
+else:
+       ANDROID_RELEASE="debug"
+
+os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')
+os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')
+
+if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):
+    print '''
+***************************************** Info ********************************
+*   Either 'Android API 21' is not installed or 'Android SDK Build Tools      *
+*   20.0.0' is not installed. The Android SDK Manager will now open. Please   *
+*   be sure to deselect all options, then select the following 2 packages:    *
+*       1. Under "Tools" select "Android SDK Build-tools" Revision 20.        *
+*       2. Under "Android 5.0.1 (API 21)" select "SDK Platform"               *
+*       3. Continue by selecting "Install 2 Packages"                         *
+*                                                                             *
+*   NOTE: If you have an http proxy, please press ctrl+c now and edit/create  *
+*         the following file in your $HOME directory as follows:              *
+*                                                                             *
+* Edit/Create file: "$HOME/.android/androidtool.cfg"                          *
+*                                                                             *
+*    http.proxyPort=<YOUR_PORT_NUMBER>                                        *
+*    sdkman.monitor.density=108                                               *
+*    http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS>                                 *
+*    sdkman.show.update.only=true                                             *
+*    sdkman.ask.adb.restart=false                                             *
+*    sdkman.force.http=true                                                   *
+*    sdkman.show.updateonly=true                                              *
+*                                                                             *
+*******************************************************************************
+
+...Opening Android SDK Manager now. Once you are finished, the build will continue.
+'''
+    os.system(android_home + '/tools/android')
+
+def ensure_libs(target, source, env):
+    return target, [source,
+                    env.get('BUILD_DIR') + 'libnotification_provider_jni.so',
+                    env.get('BUILD_DIR') + 'libnotification_provider_wrapper.so',
+                    env.get('BUILD_DIR') + 'libnotification_provider.so',
+                    env.get('BUILD_DIR') + 'libnotification_consumer_jni.so',
+                    env.get('BUILD_DIR') + 'libnotification_consumer_wrapper.so',
+                    env.get('BUILD_DIR') + 'libnotification_consumer.so']
+
+jdk_env = Environment(ENV=os.environ)
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + 
+    ' build -bservice/notification/examples/android/NotiConsumerExample/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE),
+    emitter = ensure_libs)
+jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
+cmdBuildNotificationConsumerApp=jdk_env.Gradle(target="app/apk", 
+    source=["app/src/main/java/com/sec/noticonsumerexample/MainActivity.java",
+            "app/src/main/java/com/sec/noticonsumerexample/ConsumerSample.java"])
+
+Depends(cmdBuildNotificationConsumerApp, env.get('notificationAAR'))
index 9023618..8d11640 100755 (executable)
@@ -1,21 +1,30 @@
-apply plugin: 'com.android.application'\r
-\r
-android {\r
-    compileSdkVersion 23\r
-    buildToolsVersion "23.0.1"\r
-\r
-    defaultConfig {\r
-        applicationId "sample.notification.service.iotivity.org.notificationconsumersample"\r
-        minSdkVersion 21\r
-        targetSdkVersion 23\r
-        versionCode 1\r
-        versionName "1.0"\r
-    }\r
-}\r
-\r
-dependencies {\r
-    compile fileTree(include: ['*.jar'], dir: 'libs')\r
-    compile 'com.android.support:appcompat-v7:23.0.1'\r
-    compile project(':iotivity-base-armeabi-release')\r
-    compile project(':iotivity-armeabi-notification-service-release')\r
-}\r
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 21
+    buildToolsVersion "20.0.0"
+
+    packagingOptions {
+        pickFirst 'lib/armeabi/libocstack-jni.so'
+        pickFirst 'lib/armeabi-v7a/libocstack-jni.so'
+        pickFirst 'lib/x86/libocstack-jni.so'
+    }
+
+    defaultConfig {
+        applicationId "sample.notification.service.iotivity.org.notificationconsumersample"
+        minSdkVersion 21
+        targetSdkVersion 21
+        versionCode 1
+        versionName "1.0"
+    }
+
+    lintOptions {
+        abortOnError false
+    }
+}
+
+dependencies {
+    compile fileTree(include: ['*.jar'], dir: 'libs')
+    compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar"
+    compile ":iotivity-${TARGET_ARCH}-notification-service-${RELEASE}@aar"
+}
index d79c440..f332ac2 100755 (executable)
@@ -21,7 +21,7 @@ package com.sec.noticonsumerexample;
 import android.os.Bundle;\r
 import android.os.Handler;\r
 import android.os.Message;\r
-import android.support.v7.app.AppCompatActivity;\r
+import android.app.Activity;\r
 import android.util.Log;\r
 import android.view.View;\r
 import android.widget.Button;\r
@@ -31,7 +31,7 @@ import android.widget.Toast;
 import org.iotivity.service.ns.common.TopicsList;\r
 import org.iotivity.service.ns.common.Topic;\r
 \r
-public class MainActivity extends AppCompatActivity\r
+public class MainActivity extends Activity\r
 {\r
     private final String TAG = "NS_MAIN_ACTIVITY";\r
 \r
index 6f19b47..afe1d34 100755 (executable)
@@ -1,11 +1,20 @@
 <resources>\r
 \r
-    <!-- Base application theme. -->\r
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
-        <!-- Customize your theme here. -->\r
-        <item name="colorPrimary">@color/colorPrimary</item>\r
-        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>\r
-        <item name="colorAccent">@color/colorAccent</item>\r
+    <!--\r
+        Base application theme, dependent on API level. This theme is replaced\r
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.\r
+    -->\r
+    <style name="AppBaseTheme" parent="android:Theme.Light">\r
+        <!--\r
+            Theme customizations available in newer API levels can go in\r
+            res/values-vXX/styles.xml, while customizations related to\r
+            backward-compatibility can go here.\r
+        -->\r
     </style>\r
 \r
-</resources>\r
+    <!-- Application theme. -->\r
+    <style name="AppTheme" parent="AppBaseTheme">\r
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->\r
+    </style>\r
+\r
+</resources>
\ No newline at end of file
index a1f101c..b009176 100755 (executable)
@@ -1,23 +1,28 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.\r
-\r
-buildscript {\r
-    repositories {\r
-        jcenter()\r
-    }\r
-    dependencies {\r
-        classpath 'com.android.tools.build:gradle:1.5.0'\r
-\r
-        // NOTE: Do not place your application dependencies here; they belong\r
-        // in the individual module build.gradle files\r
-    }\r
-}\r
-\r
-allprojects {\r
-    repositories {\r
-        jcenter()\r
-    }\r
-}\r
-\r
-task clean(type: Delete) {\r
-    delete rootProject.buildDir\r
-}\r
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:1.5.0'
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter()
+
+        flatDir {
+            dirs '../../../../android/notification-service/build/outputs/aar'
+            dirs '../../../../../../android/android_api/base/build/outputs/aar'
+        }
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}
diff --git a/service/notification/examples/android/NotiProviderExample/SConscript b/service/notification/examples/android/NotiProviderExample/SConscript
new file mode 100644 (file)
index 0000000..4d4c8af
--- /dev/null
@@ -0,0 +1,84 @@
+#//******************************************************************
+#//
+#// Copyright 2016 Samsung Electronics All Rights Reserved.
+#//
+#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#//
+#// Licensed under the Apache License, Version 2.0 (the "License");
+#// you may not use this file except in compliance with the License.
+#// You may obtain a copy of the License at
+#//
+#//      http://www.apache.org/licenses/LICENSE-2.0
+#//
+#// Unless required by applicable law or agreed to in writing, software
+#// distributed under the License is distributed on an "AS IS" BASIS,
+#// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#// See the License for the specific language governing permissions and
+#// limitations under the License.
+#//
+#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+import os
+import platform
+Import('env')
+
+android_home = env.get('ANDROID_HOME')
+
+ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')
+if env.get('RELEASE'):
+       ANDROID_RELEASE="release"
+else:
+       ANDROID_RELEASE="debug"
+
+os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')
+os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')
+
+if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):
+    print '''
+***************************************** Info ********************************
+*   Either 'Android API 21' is not installed or 'Android SDK Build Tools      *
+*   20.0.0' is not installed. The Android SDK Manager will now open. Please   *
+*   be sure to deselect all options, then select the following 2 packages:    *
+*       1. Under "Tools" select "Android SDK Build-tools" Revision 20.        *
+*       2. Under "Android 5.0.1 (API 21)" select "SDK Platform"               *
+*       3. Continue by selecting "Install 2 Packages"                         *
+*                                                                             *
+*   NOTE: If you have an http proxy, please press ctrl+c now and edit/create  *
+*         the following file in your $HOME directory as follows:              *
+*                                                                             *
+* Edit/Create file: "$HOME/.android/androidtool.cfg"                          *
+*                                                                             *
+*    http.proxyPort=<YOUR_PORT_NUMBER>                                        *
+*    sdkman.monitor.density=108                                               *
+*    http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS>                                 *
+*    sdkman.show.update.only=true                                             *
+*    sdkman.ask.adb.restart=false                                             *
+*    sdkman.force.http=true                                                   *
+*    sdkman.show.updateonly=true                                              *
+*                                                                             *
+*******************************************************************************
+
+...Opening Android SDK Manager now. Once you are finished, the build will continue.
+'''
+    os.system(android_home + '/tools/android')
+
+def ensure_libs(target, source, env):
+    return target, [source,
+                    env.get('BUILD_DIR') + 'libnotification_provider_jni.so',
+                    env.get('BUILD_DIR') + 'libnotification_provider_wrapper.so',
+                    env.get('BUILD_DIR') + 'libnotification_provider.so',
+                    env.get('BUILD_DIR') + 'libnotification_consumer_jni.so',
+                    env.get('BUILD_DIR') + 'libnotification_consumer_wrapper.so',
+                    env.get('BUILD_DIR') + 'libnotification_consumer.so']
+
+jdk_env = Environment(ENV=os.environ)
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + 
+    ' build -bservice/notification/examples/android/NotiProviderExample/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE),
+    emitter = ensure_libs)
+jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
+cmdBuildNotificationProviderApp=jdk_env.Gradle(target="app/apk", 
+    source=["app/src/main/java/com/sec/notiproviderexample/MainActivity.java",
+            "app/src/main/java/com/sec/notiproviderexample/NotiListener.java",
+            "app/src/main/java/com/sec/notiproviderexample/ProviderSample.java"])
+
+Depends(cmdBuildNotificationProviderApp, env.get('notificationAAR'))
old mode 100644 (file)
new mode 100755 (executable)
index 38ea4c4..c320c1c
@@ -1,19 +1,30 @@
-apply plugin: 'com.android.application'\r
-\r
-android {\r
-    compileSdkVersion 23\r
-    buildToolsVersion "23.0.1"\r
-\r
-    defaultConfig {\r
-        applicationId "sample.notification.service.iotivity.org.notificationsample"\r
-        minSdkVersion 21\r
-        targetSdkVersion 23\r
-        versionCode 1\r
-        versionName "1.0"\r
-    }\r
-}\r
-\r
-dependencies {\r
-    compile fileTree(include: ['*.jar'], dir: 'libs')\r
-    compile 'com.android.support:appcompat-v7:23.0.1'\r
-}\r
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 21
+    buildToolsVersion "20.0.0"
+
+    packagingOptions {
+        pickFirst 'lib/armeabi/libocstack-jni.so'
+        pickFirst 'lib/armeabi-v7a/libocstack-jni.so'
+        pickFirst 'lib/x86/libocstack-jni.so'
+    }
+
+    defaultConfig {
+        applicationId "sample.notification.service.iotivity.org.notificationsample"
+        minSdkVersion 21
+        targetSdkVersion 21
+        versionCode 1
+        versionName "1.0"
+    }
+
+    lintOptions {
+        abortOnError false
+    }
+}
+
+dependencies {
+    compile fileTree(include: ['*.jar'], dir: 'libs')
+    compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar"
+    compile ":iotivity-${TARGET_ARCH}-notification-service-${RELEASE}@aar"
+}
index c9d821c..481f74e 100755 (executable)
@@ -28,7 +28,6 @@ import android.content.Intent;
 import android.os.Bundle;\r
 import android.os.Handler;\r
 import android.os.Message;\r
-import android.support.v7.app.AppCompatActivity;\r
 import android.util.Log;\r
 import android.view.View;\r
 import android.widget.Button;\r
@@ -36,13 +35,14 @@ import android.widget.EditText;
 import android.widget.RadioButton;\r
 import android.widget.TextView;\r
 import android.widget.Toast;\r
+import android.app.Activity;\r
 \r
 import org.iotivity.service.ns.common.MediaContents;\r
 \r
 import java.text.DateFormat;\r
 import java.util.Date;\r
 \r
-public class MainActivity extends AppCompatActivity {\r
+public class MainActivity extends Activity {\r
 \r
     private final String TAG = "NS_MAIN_ACTIVITY";\r
     private static final int CONSUMER_SUBSCRIBED = 1;\r
index 6f19b47..afe1d34 100644 (file)
@@ -1,11 +1,20 @@
 <resources>\r
 \r
-    <!-- Base application theme. -->\r
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
-        <!-- Customize your theme here. -->\r
-        <item name="colorPrimary">@color/colorPrimary</item>\r
-        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>\r
-        <item name="colorAccent">@color/colorAccent</item>\r
+    <!--\r
+        Base application theme, dependent on API level. This theme is replaced\r
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.\r
+    -->\r
+    <style name="AppBaseTheme" parent="android:Theme.Light">\r
+        <!--\r
+            Theme customizations available in newer API levels can go in\r
+            res/values-vXX/styles.xml, while customizations related to\r
+            backward-compatibility can go here.\r
+        -->\r
     </style>\r
 \r
-</resources>\r
+    <!-- Application theme. -->\r
+    <style name="AppTheme" parent="AppBaseTheme">\r
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->\r
+    </style>\r
+\r
+</resources>
\ No newline at end of file
index a1f101c..b009176 100644 (file)
@@ -1,23 +1,28 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.\r
-\r
-buildscript {\r
-    repositories {\r
-        jcenter()\r
-    }\r
-    dependencies {\r
-        classpath 'com.android.tools.build:gradle:1.5.0'\r
-\r
-        // NOTE: Do not place your application dependencies here; they belong\r
-        // in the individual module build.gradle files\r
-    }\r
-}\r
-\r
-allprojects {\r
-    repositories {\r
-        jcenter()\r
-    }\r
-}\r
-\r
-task clean(type: Delete) {\r
-    delete rootProject.buildDir\r
-}\r
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:1.5.0'
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter()
+
+        flatDir {
+            dirs '../../../../android/notification-service/build/outputs/aar'
+            dirs '../../../../../../android/android_api/base/build/outputs/aar'
+        }
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}
diff --git a/service/notification/examples/android/SConscript b/service/notification/examples/android/SConscript
new file mode 100644 (file)
index 0000000..db1a1dc
--- /dev/null
@@ -0,0 +1,22 @@
+#//******************************************************************
+#//
+#// Copyright 2016 Samsung Electronics All Rights Reserved.
+#//
+#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#//
+#// Licensed under the Apache License, Version 2.0 (the "License");
+#// you may not use this file except in compliance with the License.
+#// You may obtain a copy of the License at
+#//
+#//      http://www.apache.org/licenses/LICENSE-2.0
+#//
+#// Unless required by applicable law or agreed to in writing, software
+#// distributed under the License is distributed on an "AS IS" BASIS,
+#// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#// See the License for the specific language governing permissions and
+#// limitations under the License.
+#//
+#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+SConscript('NotiProviderExample/SConscript')
+SConscript('NotiConsumerExample/SConscript')