Friday, May 29, 2015

Android Studio 1.3 Release

Android Studio 1.3 Release
Link -> http://tools.android.com/download/studio/canary/1-3

Android Studio 1.3 <Preview 2>
Windows: http://dl.google.com/dl/android/studio/ide-zips/1.3.0.1/android-studio-ide-141.1972460-windows.zip (266 MB)
Mac: http://dl.google.com/dl/android/studio/ide-zips/1.3.0.1/android-studio-ide-141.1972460-mac.zip (265 MB)
Linux: http://dl.google.com/dl/android/studio/ide-zips/1.3.0.1/android-studio-ide-141.1972460-linux.zip (264 MB)




Note:
Use /usr/libexec/java_home -v 1.7 command on a Mac's terminal shell to figure out where is your java 1.7 home directory

Need JDK7 for Mac OSX here, if not already installed http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Gradle Offline mode is here
See here for building apk files
http://stackoverflow.com/questions/16709848/build-unsigned-apk-file-with-android-studio
app/build.gradle    Select all
apply plugin: 'android' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "com.mycompany.PeamonCalculator" minSdkVersion 8 targetSdkVersion 16 versionCode 1 versionName "1.0" archivesBaseName = "PeamonCalculator" + versionName } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } }

This is another build.gradle for building and linking native_app_glue static library in ndk (ugly but works in pre Android Studio 1.3)
app/build.gradle    Select all
apply plugin: 'android' def ndkFolder = file(plugins.getPlugin('com.android.application').sdkHandler.getNdkFolder()).absolutePath android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "com.beginndkgamecode.hellodroid" minSdkVersion 8 targetSdkVersion 20 versionCode 1 versionName "1.0" archivesBaseName = "HELLODRIOD" + versionName ndk { abiFilters "x86, armeabi-v7a, armeabi" moduleName "hellodroid" cFlags "-I"+ndkFolder+"/sources/android/native_app_glue" ldLibs "EGL", "GLESv2", "android", "log", file(projectDir).absolutePath+"/libs/local/\$(TARGET_ARCH_ABI)/libandroid_native_app_glue.a" } } // call regular ndk-build script task staticLibBuild(type: Exec, description: 'Build Static Library files') { // for windows: commandLine ndkFolder+'/ndk-build.cmd', commandLine ndkFolder+'/ndk-build', 'APP_BUILD_SCRIPT='+ndkFolder+'/sources/android/native_app_glue/Android.mk', 'NDK_APPLICATION_MK='+file(projectDir).absolutePath+'/src/main/jni/Application.mk', 'NDK_PROJECT_PATH='+ndkFolder, 'NDK_OUT='+file(projectDir).absolutePath+'/libs' } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn staticLibBuild } task cleanLibDir(type: Delete) { delete 'libs' } clean.dependsOn cleanLibDir productFlavors { x86 { ndk { abiFilters "x86" versionCode 2 } } armv7 { ndk { abiFilters "armeabi-v7a" versionCode 2 } } arm { ndk { abiFilters "armeabi" versionCode 2 } } } buildTypes { debug { minifyEnabled false zipAlignEnabled true jniDebuggable true renderscriptDebuggable true } release { minifyEnabled false zipAlignEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } }

C/C++ Debugging is very limited in the first few previews of Android Studio 1.3, so logging might be helpful in C/CC source files like this below.
main.cpp    Select all
#include <android/log.h> ... #define ALOG(...) ((void)__android_log_print(ANDROID_LOG_INFO, __FILE__, __VA_ARGS__)) ... ALOG("This message came from C at line %d.", __LINE__);

For the source code of HelloDroid and PeamonCalculator, please see here and here.

Want to change to the awesome dark background theme. It is here


Android Studio 1.3 Release & 1.4 Preview using gradle-experimental

app/build.gradle (Module)   Select all
apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.0" defaultConfig.with { applicationId = "com.beginndkgamecode.hellodroid" minSdkVersion.apiLevel = 8 targetSdkVersion.apiLevel = 23 versionCode = 1 versionName = "1.0" archivesBaseName = "HELLODRIOD_" + versionName } } android.ndk { moduleName = "hellodroid" /* * Other ndk flags configurable here are * cppFlags += "-fno-rtti" * cppFlags += "-fno-exceptions" * ldLibs = ["android", "log"] * stl = "system" */ cppFlags += "-I${file("src/main/jni/native_app_glue")}".toString() ldLibs += ["android", "log", "EGL", "GLESv2"] } android.buildTypes { release { minifyEnabled = false proguardFiles += file('proguard-rules.txt') } debug { ndk.with { debuggable = true } } } android.productFlavors { // for detailed abiFilter descriptions, refer to "Supported ABIs" @ // https://developer.android.com/ndk/guides/abis.html#sa create("arm") { ndk.abiFilters += "armeabi" } create("arm7") { ndk.abiFilters += "armeabi-v7a" } create("arm8") { ndk.abiFilters += "arm64-v8a" } create("x86") { ndk.abiFilters += "x86" } create("x86-64") { ndk.abiFilters += "x86_64" } // To include all cpu architectures, leaves abiFilters empty create("all") } }


app/build.gradle (Project)   Select all
// build.gradle // Classpath for the plugin is com.android.tools.build:gradle-experimental instead of com.android.tools.build:gradle. // The current version is 0.2.0. // 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-experimental:0.2.0' } } allprojects { repositories { jcenter() } }


./gradle/wrapper/gradle-wrapper.properties    Select all
#The new plugin supports only gradle-2.5. distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip