Use Android Studio to develop native Titanium Android Modules
You as a developer can build and edit your Android modules inside the Titanium Studio. For this you have to add some (JDT-) plugins to Studio. In last time this makes trouble.
First reason: the receipt is from March 2016 and works with Luna. Luna is released at Juni 2014, next version Mars is from Juni 2015. Project seems to be dead. Chinese would say: 金蟬脱殼 (Slough off the cicada's golden shell).
An alternative way is to use the alive Android Studio.
Objectiv of this receipt is to explaine how you can develope Titanium modules with Android Studio.
This tutorial is based on the instructions from drauggres via the Titanium Slack Community, thank you!!
If you have always a working module you can directly continue with Starting Android Studio
Create a new Project
Example:
ti create --type module --name test --platform android --id com.company.test --workspace-dir ./
Or simplified:
ti create -t module -n test -p android --id com.company.test -d ./
Note: The same goes for the Appc-CLI and appc new [args]
.
This command creates a folder test
with it's subfolders.
Sample Output
```
[INFO] Creating module project
[INFO] Template directory: /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/templates/module/default
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/templates/module/default/template/LICENSE => /Users/fuerst/Desktop/AndroidStudioTitanium/test/LICENSE
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/templates/module/default/template/README.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/README
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/templates/module/default/template/assets/README.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/assets/README
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/templates/module/default/template/documentation/index.md.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/documentation/index.md
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/templates/module/default/template/example/app.js.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/example/app.js
[DEBUG] Detecting Android environment...
[INFO] Copying android platform resources
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/.classpath.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/.classpath
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/.project.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/.project
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/.settings/org.eclipse.jdt.apt.core.prefs.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/.settings/org.eclipse.jdt.apt.core.prefs
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/.settings/org.eclipse.jdt.core.prefs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/.settings/org.eclipse.jdt.core.prefs
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/Resources/README.md => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/Resources/README.md
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/build.properties.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/build.properties
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/build.xml.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/build.xml
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/lib/README => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/lib/README
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/manifest.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/manifest
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/platform/README.md => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/platform/README.md
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/src/{{ModuleIdAsFolder}}/ExampleProxy.java.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/src/com/company/test/ExampleProxy.java
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/src/{{ModuleIdAsFolder}}/{{ModuleNameCamel}}Module.java.ejs => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/src/com/company/test/TestModule.java
[DEBUG] Copying /Library/Application Support/Titanium/mobilesdk/osx/7.0.1.GA/android/templates/module/default/template/android/timodule.xml => /Users/fuerst/Desktop/AndroidStudioTitanium/test/android/timodule.xml
[INFO] Project created successfully in 1s 318ms
```
Overview: `ti create`
```
user$ ti create -help
Titanium Command-Line Interface, CLI version 5.0.11, Titanium SDK version 7.0.1.GA
Copyright (c) 2012-2015, Appcelerator, Inc. All Rights Reserved.
Please report bugs to http://jira.appcelerator.org/
Usage: titanium create --type [--force] [--log-level ]
Creates a new Titanium application, native module, or Apple Watch™ app.
Apple, iPhone, and iPad are registered trademarks of Apple Inc. Apple Watch is a trademark of Apple
Inc.
Android is a trademark of Google Inc.
Create Flags:
-f, --force force project creation even if path already exists
Create Options:
--log-level minimum logging level [trace, debug, info, warn, error]
-t, --type the type of project to create [app, applewatch, module]
Create --type=app Options:
--id the App ID in the format 'com.companyname.appname'
--template the name of the project template, path to template dir, path to zip
file, or url to zip file [default: default]
-d, --workspace-dir the directory to place the project in
-n, --name the name of the project
-p, --platforms one or more target platforms. [all, android, mobileweb, iphone,
ipad, windows]
-u, --url your company/personal URL
Create --type=applewatch Options:
--template the name of the project template, path to template dir, path to zip
file, or url to zip file [default: watchos2-swift]
-d, --project-dir the directory containing the project [default: .]
-n, --name the name of the watch app
Create --type=module Options:
--id the App ID in the format 'com.companyname.appname'
--template the name of the project template, path to template dir, path to zip
file, or url to zip file [default: default]
-d, --workspace-dir the directory to place the project in
-n, --name the name of the project
-p, --platforms one or more target platforms. [all, android, mobileweb, ios,
windows]
Global Flags:
--no-banner disable Titanium version banner
--no-colors disable colors
--no-progress-bars disable progress bars
--no-prompt disable interactive prompting
-h, --help displays help
-q, --quiet suppress all output
-v, --version displays the current version
Global Options:
--config serialized JSON string to mix into CLI config
--config-file path to CLI config file [default: /Users/fuerst/.titanium/config.json]
-s, --sdk Titanium SDK version to use to bootstrap SDK-level commands and parse the
tiapp.xml; actual Titanium SDK used determined by in the
tiapp.xml [default: latest]
```
Installing Android Studio
After downloading Android Studio you can install the dmg.
And install the required SDK:
Starting Android Studio
Add Project SDK
If you open an existing project and point to our test
- folder, then there is nothing to show on the left side bar.
Ok, next we add the SDK to project settings by calling this dialog:
Menu: File/Projectstructure
Add Android Build Files
First you have to create some folders:
cd <module_path>
mkdir platform/android
mkdir platform/android/res
For accessing AndroidManifest you have to build an empty project:
ti build -p android -b
Now you can add the AndroidManifest.xml from folder build/intermediates/manifests/aapt/AndroidManifest.xml
After this preparations you can add the facets to project:
- Manifest:
<module_path>/android/build/intermediates/manifests/aapt/AndroidManifest.xml
- Resources:
<module_path>/android/platform/android/res
- Assets:
<module_path>/android/assets
- Native libs:
<module_path>/android/libs
Important: Also uncheck Generate sources automatically
Add Titanium libraries
Add Titanium libraries (titanium.jar
, kroll-common.jar
, kroll-apt.jar
) (edited)
In the end you will see:
And now you can edit the module:
Configuring Source root
Mark src
directory (right click -> Mark Directory As
) as Sources Root
.
Notes
See the test/
directory for details!
Potential pitfalls
Unregistered VCS root detected
The directory /Users/fuerst/Desktop/AndroidStudioTitanium is under Git, but is not registered in the Settings.
In this case you have to enable git.
Can't start Git: /usr/local/bin/git
The path to Git executable is probably not valid.
In this case you can find with whereis git
and then you have to edit the path to i.e. /usr/bin/git
.
Next steps/links
If you only want create apps with javascript you have to sources howto work with ATOM:
All what you need to create native apps with a lot of details.
dl;dr:
- Install of ATOM
apm install appcelerator-titanium
https://github.com/drauggres/ti.gradle.fake