mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-02 04:42:46 +08:00
sweet one line building!
This commit is contained in:
parent
816341030f
commit
bb7b973bf0
36
README.md
36
README.md
@ -1,37 +1,29 @@
|
||||
PhoneGap Android
|
||||
=============================================================
|
||||
PhoneGap Android is an Android application library that allows for PhoneGap-based projects to be built for the Android Platform. PhoneGap-based applications are, at the core, an application written in web-based languages, generally HTML, CSS and JavaScript.
|
||||
PhoneGap/Android
|
||||
================
|
||||
PhoneGap/Android is an Android application library that allows for PhoneGap based projects to be built for the Android Platform. PhoneGap based applications are, at the core, an application written with web technology: HTML, CSS and JavaScript.
|
||||
|
||||
Pre-requisites
|
||||
-------------------------------------------------------------
|
||||
* Java JDK 1.5
|
||||
* Android SDK Package [http://developer.android.com](http://developer.android.com)
|
||||
* Apache ANT (For build script)
|
||||
* Ruby
|
||||
--------------
|
||||
- Java JDK 1.5
|
||||
- Android SDK Package [http://developer.android.com](http://developer.android.com)
|
||||
- Apache ANT
|
||||
- Ruby
|
||||
|
||||
Recommended:
|
||||
----------------------------------------------------------------
|
||||
* Eclipse (Recommended for back-end debugging, not required)
|
||||
Recommended
|
||||
-----------
|
||||
- Eclipse (Great for debugging and extending PhoneGap/Android with your own Java plugins.)
|
||||
|
||||
Getting Started with PhoneGap Android
|
||||
Getting Started with PhoneGap/Android
|
||||
--------------------------------------
|
||||
|
||||
1. Clone the repository using git, from command line: git clone git://github.com/phonegap/phonegap-android.git
|
||||
2. Run the following command:
|
||||
1. From the root of this repo run the following command:
|
||||
|
||||
./droidgap <android_sdk_path> <name> <package_name> <www> <path>
|
||||
|
||||
Params
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
7. Run 'ruby build.rb <app-name> <package_name> <wwwdir> <path>', where:
|
||||
- app-name: Name of application without spaces
|
||||
- package name: Java namespace of package ( i.e. com.nitobi.demo). This must be unique otherwise it won't load properly on your phone
|
||||
- www-dir: www directory which includes an icon.png file for the icon
|
||||
- path: The path to copy the final project assets into, i.e. the final build path
|
||||
8. Now you can use the generated Android code that is located in the 'path' directory from the above step and do what you want with it: import into Eclipse to test with the simulator or otherwise.
|
||||
|
||||
Using Eclipse with PhoneGap
|
||||
|
35
droidgap
35
droidgap
@ -13,6 +13,7 @@ class Build
|
||||
create_android
|
||||
generate_manifest
|
||||
copy_libs
|
||||
add_name_to_strings
|
||||
write_java
|
||||
end
|
||||
|
||||
@ -38,25 +39,41 @@ class Build
|
||||
manifest = ""
|
||||
open('framework/AndroidManifest.xml', 'r') do |old|
|
||||
manifest = old.read
|
||||
manifest.gsub! 'android:versionCode="5"', 'android:versionCode="1"'
|
||||
manifest.gsub! 'package="com.phonegap"', "package=\"#{ @pkg }\""
|
||||
manifest.gsub! 'android:name=".StandAlone"', "android:name=\".#{ @name }\""
|
||||
manifest.gsub! 'android:minSdkVersion="5"', 'android:minSdkVersion="3"'
|
||||
end
|
||||
open("#{ @path }/AndroidManifest.xml", 'w') {|x| x.puts manifest }
|
||||
open("#{ @path }/AndroidManifest.xml", 'w') { |x| x.puts manifest }
|
||||
end
|
||||
|
||||
# copies stuff from framework into the project
|
||||
#
|
||||
# TODO need to allow for www import
|
||||
# - copy www into #{ @path }/assets/www
|
||||
# - copy www/icon.png into #{ @path }/res/drawable/icon.png
|
||||
#
|
||||
# TODO need to allow for www import inc icon
|
||||
def copy_libs
|
||||
`mkdir -p #{ @path }/assets/wwww`
|
||||
`cp framework/phonegap.jar #{ @path }/libs`
|
||||
`cp framework/res/values/strings.xml #{ @path }/res/values/strings.xml`
|
||||
`cp -R framework/res #{ @path }/res`
|
||||
`cp -R example #{ @path }/assets/wwww`
|
||||
`cp framework/res/layout/main.xml #{ @path }/res/layout/main.xml`
|
||||
`cp framework/res/layout/preview.xml #{ @path }/res/layout/preview.xml`
|
||||
%w(drawable-hdpi drawable-ldpi drawable-mdpi).each do |e|
|
||||
`cp framework/res/drawable/icon.png #{ @path }/res/#{ e }/icon.png`
|
||||
end
|
||||
`cp -R example #{ @path }/assets`
|
||||
`mv #{ @path }/assets/example #{ @path }/assets/www`
|
||||
end
|
||||
|
||||
# puts app name in strings
|
||||
def add_name_to_strings
|
||||
x = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
|
||||
<resources>
|
||||
<string name=\"app_name\">#{ @name }</string>
|
||||
<string name=\"go\">Snap</string>
|
||||
</resources>
|
||||
"
|
||||
open("#{ @path }/res/values/strings.xml", 'w') do |f|
|
||||
f.puts x.gsub(' ','')
|
||||
end
|
||||
end
|
||||
|
||||
# this is so fucking unholy yet oddly beautiful
|
||||
# not sure if I should thank Ruby or apologize for this abusive use of string interpolation
|
||||
@ -81,7 +98,7 @@ class Build
|
||||
dir = "#{ @path }/src/#{ @pkg.gsub '.', '/' }";
|
||||
cls = "#{ @name }.java"
|
||||
pth = File.join(dir,cls)
|
||||
open(pth,'w') { |f| f.puts j }
|
||||
open(pth,'w') { |f| f.puts j.gsub(' ','') }
|
||||
end
|
||||
#
|
||||
end
|
||||
|
@ -24,7 +24,6 @@ public final class R {
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f040000;
|
||||
public static final int go=0x7f040002;
|
||||
public static final int url=0x7f040001;
|
||||
public static final int go=0x7f040001;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">PhoneGap</string>
|
||||
<string name="url">file:///android_asset/www/index.html</string>
|
||||
<string name="go">Snap</string>
|
||||
<string name="go">Snap</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user