From c5ac3b7d44c1360c5d9ab1380d7d0a688f1b5cd0 Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Mon, 8 Aug 2016 18:25:09 +0900 Subject: [PATCH] Enable gradle build for Easy setup app for Android with scons Along with the patch 10093, this is for build easy setup Android app with gradle build in scons. Change-Id: Ib99cb63cfe8859766b8263e5669cb2cd9d9ddba9 Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/10095 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- service/easy-setup/mediator/richsdk/SConscript | 4 ++ .../mediator/android/EasySetup/EasySetup.iml | 19 ++++++ .../mediator/android/EasySetup/app/build.gradle | 79 ++++++++++++++++------ .../android/EasySetup/app/proguard-rules.pro | 17 +++++ .../mediator/android/EasySetup/build.gradle | 26 ++++++- .../mediator/android/EasySetup/gradle.properties | 47 +++++++++++++ .../mediator/android/EasySetup/settings.gradle | 22 +++++- .../sampleapp/mediator/android/SConscript | 78 +++++++++++++++++++++ 8 files changed, 269 insertions(+), 23 deletions(-) create mode 100755 service/easy-setup/sampleapp/mediator/android/EasySetup/EasySetup.iml create mode 100644 service/easy-setup/sampleapp/mediator/android/EasySetup/app/proguard-rules.pro mode change 100644 => 100755 service/easy-setup/sampleapp/mediator/android/EasySetup/build.gradle create mode 100644 service/easy-setup/sampleapp/mediator/android/EasySetup/gradle.properties create mode 100644 service/easy-setup/sampleapp/mediator/android/SConscript diff --git a/service/easy-setup/mediator/richsdk/SConscript b/service/easy-setup/mediator/richsdk/SConscript index 2ae46dc..09dd228 100644 --- a/service/easy-setup/mediator/richsdk/SConscript +++ b/service/easy-setup/mediator/richsdk/SConscript @@ -143,6 +143,10 @@ if target_os in ['android']: if target_os in ['linux']: SConscript('../../sampleapp/mediator/linux/richsdk_sample/SConscript') +if target_os in ['android']: + SConscript('../../sampleapp/mediator/android/SConscript') + + ###################################################################### #Build UnitTestcases for Mediator[RichSDK] ################################################ ###################### diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/EasySetup.iml b/service/easy-setup/sampleapp/mediator/android/EasySetup/EasySetup.iml new file mode 100755 index 0000000..b8f4dc9 --- /dev/null +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/EasySetup.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/build.gradle b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/build.gradle index c249744..11c057b 100644 --- a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/build.gradle +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/build.gradle @@ -1,21 +1,58 @@ -apply plugin: 'com.android.application' -android { - compileSdkVersion 21 - buildToolsVersion '21.1.2' - - defaultConfig { - applicationId "org.iotivity.service.easysetup" - minSdkVersion 21 - targetSdkVersion 21 - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' - } - } -} - -dependencies { -} \ No newline at end of file +//****************************************************************** +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "20.0.0" + + defaultConfig { + applicationId "org.iotivity.service.easysetup" + minSdkVersion 21 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + lintOptions { + abortOnError false + } +} +repositories { + flatDir { + dirs "../../../../../../../android/android_api/base/build/outputs/aar/", "../../../../../mediator/richsdk/android/EasySetupCore/build/outputs/aar/" + } +} + +try { + dependencies { + compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar" + compile ":EasySetupCore-${RELEASE}@aar" + } +} catch (all) { + print "${ERROR_MSG}" + assert all +} diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/proguard-rules.pro b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/proguard-rules.pro new file mode 100644 index 0000000..d26150c --- /dev/null +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/rahul/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/build.gradle b/service/easy-setup/sampleapp/mediator/android/EasySetup/build.gradle old mode 100644 new mode 100755 index 81f1373..c02583e --- a/service/easy-setup/sampleapp/mediator/android/EasySetup/build.gradle +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/build.gradle @@ -1,10 +1,34 @@ +//****************************************************************** +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + // 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:2.1.2' + classpath 'com.android.tools.build:gradle:1.3.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files } } diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/gradle.properties b/service/easy-setup/sampleapp/mediator/android/EasySetup/gradle.properties new file mode 100644 index 0000000..23f541f --- /dev/null +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/gradle.properties @@ -0,0 +1,47 @@ +# +# //****************************************************************** +# // +# // 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. +# // +# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# + +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# 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 +TARGET_ARCH=armeabi +RELEASE=release +SECURED=1 +ERROR_MSG="if building examples from android-studio, you might need to modify the default TARGET_ARCH\ + and RELEASE in /android/examples/gradle.properties,\ + if your aar file has different values for TARGET_ARCH and RELEASE" + diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/settings.gradle b/service/easy-setup/sampleapp/mediator/android/EasySetup/settings.gradle index d3db109..a86cfbe 100755 --- a/service/easy-setup/sampleapp/mediator/android/EasySetup/settings.gradle +++ b/service/easy-setup/sampleapp/mediator/android/EasySetup/settings.gradle @@ -1 +1,21 @@ -include ':app' +//****************************************************************** +// +// 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. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +include ':app' diff --git a/service/easy-setup/sampleapp/mediator/android/SConscript b/service/easy-setup/sampleapp/mediator/android/SConscript new file mode 100644 index 0000000..54d9624 --- /dev/null +++ b/service/easy-setup/sampleapp/mediator/android/SConscript @@ -0,0 +1,78 @@ +#//****************************************************************** +#// +#// 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= * +* sdkman.monitor.density=108 * +* http.proxyHost= * +* 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') + +#SConscript("../../../../../../android/android_api/SConscript") + +def ensure_libs(target, source, env): + return target, [source, env.get('BUILD_DIR') + 'liboc.so', env.get('BUILD_DIR') + 'liboc_logger.so'] + +jdk_env = Environment(ENV=os.environ) +jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + + ' build -bservice/easy-setup/sampleapp/mediator/android/EasySetup/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE), + emitter = ensure_libs) +jdk_env['BUILD_DIR'] = env.get('BUILD_DIR') +cmdBuildEasysetupApp=jdk_env.Gradle(target="EasySetup/app/apk", + source="EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java") + +Depends(cmdBuildEasysetupApp, env.get('baseAAR')) \ No newline at end of file -- 2.7.4