Android Studio で簡単に jar をつくる手順はないのかと

ふと, こんな.

https://twitter.com/malcheese2/status/457027182133387264

Android Studio 最新版 0.5.5 でどうしたらいいのだろうか.

Create a standalone library with Android Studio | Geek Garage

apply plugin: ‘android'

apply plugin: 'android-library’

./gradlew clean
./gradlew aR

aR=assembleRelease

build/libs/ 以下に .aar ファイルが作成される.

このファイルを別プロジェクトの libs/ 以下にコピーして,依存の記述をすればよし.

Referencing a local aar file in Android Studio | Geek Garage

dependencies {
    compile files('libs/mylib.aar')
}

で「aar」とは何なのか.

Building Android applications with Gradle - Tutorial

Gradle supports a format called Android ARchive (AAR) . An AAR is similar to a JAR file, but it can contain resources as well as compiled bytecode. This allows that an AAR file is included similar to a JAR file

.aar ファイルは zip 圧縮されたファイルで以下が含まれている.

/AndroidManifest.xml (mandatory)
/classes.jar (mandatory)
/res/ (mandatory)
/R.txt (mandatory)
/assets/ (optional)
/libs/*.jar (optional)
/jni//*.so (optional)
/proguard.txt (optional)
/lint.jar (optional)

AAR Format - Android Tools Project Site

Gradle 本家サイトドキュメントなどを見てると広く深いのですが
Android Studio 関連のそこらの話を含め, 以下が一番わかりやすい.

Library projects - Android Tools Project Site

Gradle Plugin User Guide - Android Tools Project Site

で思うのが, .aar から .jar に変換できないか.

java - How to convert AAR to JAR - Stack Overflow

The AAR file consists of a JAR file and some resource files. Here are the steps to convert:

1. Extract the AAR file using standard zip extract
2. Find the classes.jar file in the extracted files
3. Rename it to your liking and use the wanted jar file in your project

Android Studio 左のツリービューからは見えない.

build_libs

ので, ターミナルから確認する.

~/AndroidStudio/SampleProject/volley/build/libs $ unzip -Z volley.aar
Archive:  volley.aar   80932 bytes   5 files
-rw-r--r--  2.0 unx      460 b- defN 23-Mar-14 22:33 AndroidManifest.xml
-rw-r--r--  2.0 unx    89580 b- defN 23-Mar-14 22:33 classes.jar
drwxr-xr-x  2.0 unx        0 b- defN 23-Mar-14 22:33 assets/
drwxr-xr-x  2.0 unx        0 b- defN 13-Feb-14 13:55 jni/
drwxr-xr-x  2.0 unx        0 b- defN 23-Mar-14 22:33 res/
5 files, 90040 bytes uncompressed, 80440 bytes compressed:  10.7%

.aar ファイルは zip 形式なので展開して class.jar をリネームすればよし, と.


AndroidStudio や Gradle ネタも掲載 オライリー「実践 Android Developer Tools」

和訳版がリリースするらしいです.

Android Developer Tools Essentials - O'Reilly MediaO_Reilly_Japan_-_実践_Android_Developer_Tools

O'Reilly Japan - 実践 Android Developer Tools

原書はこちら.

Android_Developer_Tools_Essentials - O_Reilly_Media

Android Developer Tools Essentials - O'Reilly Media

Android Studio や Gradle のネタもあるらしいです.

6章 Android Studioによる開発
    6.1 Android Studioをインストールする
        6.1.1 Android SDKの導入
        6.1.2 プロジェクトのデフォルトの位置
    6.2 Android Studio IDEの解剖
        6.2.1 パネル
        6.2.2 ツールバー
        6.2.3 Android Studioの便利なコマンド
        6.2.4 ナビゲーション
    6.3 Androidプロジェクトの新しい構造
        6.3.1 新しいファイル構造へのツアー
        6.3.2 Androidプロジェクトを実行、デバッグする
    6.4 新しいAndroidコンポーネントを作る
    6.5 レイアウトデザイナとレイアウトプレビュー
        6.5.1 レイアウトデザイナ
        6.5.2 レイアウトプレビュー
    6.6 APKを生成する
    6.7 MavenやGradleとのやり取り
        6.7.1 Mavenを操作する
        6.7.2 Gradleを操作する
    6.8 VCSとの統合
    6.9 EclipseからAndroid Studioに移行するには
    6.1 0 Android Studioのちょっとしたテクニック
        6.10.1 リファクタリングとコード生成
        6.10.2 その他のショートカット
    9.5 Gradleベースのビルドツール
        9.5.1 Gradleをインストールする
        9.5.2 複数のビルドバリエーションを作る
        9.5.3 ビルドファイル
        9.5.4 ビルドタスク
        9.5.5 EclipseからGradle buildを実行する
    9.6 Mavenツールを使う

和訳版は, 2014年4月23日のリリース.

原書が 2013年8月のリリース.

そんなに古くもないので, 予約しておきました.

英語が理解できる人は, 安く早く購入できるのでいいですよね.


Android Studio の設定で「バージョン」の記述してるとこありすぎね?

あちこちに, 似たようなバージョン的な記述あります Android Studio.

build_gradle

Project_Structure

プロジェクトの改修や移動などで変更しなければならないとき

どこを編集したらいいのか.

いや, 同期されるのか

いや, 優先順位が決まっているのか

どうなのか よくわかりません.

項目もたくさんあります.

どんなのあるか並べてみます.

Default Settings

[Quick Start]-[Configure]-[Project Default]-[Settings]
[File]-[Other Settings]-[Default Settings]

+ Compiler
  + Java Compiler
    + Project byte code version(JDK Default(1.7))

Preferences

Default Project Structure

[Quick Start]-[Configure]-[Project Default]-[Project Structure]
[File]-[Other Settings]-[Default Project Structure]

+ Project Settings
  + Project
    + Project SDK(Android API 19 Platform)
    + Project language level(7.0 - Diamonds, ARM, multi-catch etc.)
+ Platform Settings
  + SDKs
    + Build target(Android 2.3.3)
  + JDK location(/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home)

Project_Structure
Project_Structure 2

Project Structure

[File]-[Project Structure]

+ Project Settings
  + Modules
    + Properties
      + Android Plugin Version(0.9.1)
      + Compile Sdk Version(19)
      + Build Tools Version(19.0.3)
    + Dependencies
      + (com.android.support:support-v4:19.0.0)
      + (com.android.support:appcompat-v7:19.0.0)
      + (com.google.android.gms:play-service:+)
+ Platform Settings
  + Android SDK
    + JDK location(/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home)

Project_Structure

AndroidManifest.xml

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="19" />

build.gradle

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.1'
    }
}

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.3'
    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.0.0'
    compile 'com.android.support:appcompat-v7:19.0.0'
    compile 'com.google.android.gms:play-services:+'
}

設定項目やエラー後に再設定しようとしても, 今度は, 設定画面にたどりつけなかったりします.

面倒なので表にしてみます.

続きを読む >>


30秒でみるクソな Android アプリ UX たち

脳みそに刻む意味で手間をかけてキャプる.

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 2

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 3

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 4

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 5

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 6

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 7

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 8

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 9

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 10

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 11

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 12

Android_Design_in_Action__Common_UX_Issues__Japanese__-_YouTube 13

SDKを最新にして, そのフレームを使って作るとほとんどクリアーできると思う.

非Androidな人が紙で画面構成を作るとこうなっちゃうのだろうけど, 実際, 一般アプリユーザーはどう思うのだろうかー.

以下, Google発ソース動画.


パソコン上で Android を試せる「Genymotion」で GooglePlayStore を使う

公式エミュレータとの比較になるのだけれども。

Genymotion

デメリット

・Geniymotionにアカウント登録が必要。
ダウンロード時、メールアドレス等の登録が必要。

・VirtualBox のインストールが必須。
ダウンロード後、ダブルクリックでインストール完了。

・起動できないアプリもある。
DRMとか課金系とか、厳しいアプリは起動できないように思える。

・動画が見れない。

メリット

・サクサク快適。

起動が早い。低スペックなマシンでは動かなかったNexus10も軽快にうごく。

・インストール、設定が簡単。

公式では、同じ kitkat(API19)でも、intelx86 とか、arm とか、snapshot が、とかあるけども簡単に avd の作成ができる。
対応機種は少ないが機種名から、その機種の最新のOSバージョンが設定されるので便利。例えば、Nexus S なら 2.3.7 とか。
Kitkatならカラー絵文字もフツーに表示されるし、表示サイズもパソコンディスプレイサイズに合わせて表示されている。

・Google Play Store が利用できる。

arm コンバータと、gapps のzipアーカイブをGUI上にドラッグアンドドロップするだけでフラッシュまで完了できる。楽ちん。
ストア上の掲載情報や公開されているapkを実際にインストールできるので間違いがない。

・文字入力、カーソルキーで画面遷移や操作ができる。

結構でかい。パソコンで矢印(ポインタ)を移動させながらのドラッグとかスワイプほどダルい操作はない。

なんせ、動作がキビキビで快速なのが最大のメリット。デフォルト設定でこの快適感。インストールから起動までの作業時間もほんの数分。

ちと、Chromeが不安定に思えるのだがまあいいか。

AndroidStudioプラグインもあるよ。

JetBrains Plugin Repository :: Genymotion

jenkins に。

Use Genymotion with Jenkins for Android testing | Genymobile Blog

で、これって、Googleアカウントがあれば、パソコン上で、Androidを*ある程度*お試しできるよなあ、と。

続きを読む >>