mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
generating apps works; needs to build js from assets
This commit is contained in:
parent
923c29aa2b
commit
816341030f
19
README.md
19
README.md
@ -15,15 +15,18 @@ Recommended:
|
||||
|
||||
Getting Started with PhoneGap Android
|
||||
--------------------------------------
|
||||
1. Make sure you have Ruby and the nokogiri gem installed. Run 'gem list' to see a list of installed Ruby gems, and 'gem install nokogiri' from command-line if you don't have it.
|
||||
2. Clone the repository using git, from command line: git clone git://github.com/phonegap/phonegap-android.git
|
||||
3. Run 'cd phonegap-android/framework'
|
||||
4. Create a local.properties file with the following line in it:
|
||||
|
||||
sdk-location=/path/to/your/androidsdk
|
||||
|
||||
5. Run 'ant jar' - this will create the phonegap.jar file and build a fresh phonegap.js for use in your HTML/JS/CSS-based application (for accessing native functionality).
|
||||
6. cd back to the root directory (cd ..)
|
||||
1. Clone the repository using git, from command line: git clone git://github.com/phonegap/phonegap-android.git
|
||||
2. Run the following command:
|
||||
|
||||
./droidgap <android_sdk_path> <name> <package_name> <www> <path>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
35
droidgap
35
droidgap
@ -1,25 +1,34 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
class Build
|
||||
def start(*args)
|
||||
@android_sdk_path, @name, @pkg, @www, @path = args
|
||||
|
||||
attr_reader :android_sdk_path, :name, :pkg, :www, :path
|
||||
|
||||
def initialize(*a)
|
||||
@android_sdk_path, @name, @pkg, @www, @path = a
|
||||
end
|
||||
|
||||
# runs the build script
|
||||
def run
|
||||
build_jar
|
||||
create_android
|
||||
generate_manifest
|
||||
copy_libs
|
||||
write_java
|
||||
end
|
||||
end
|
||||
|
||||
# removes local.properties and recreates based on android_sdk_path
|
||||
# then generates framework/phonegap.jar
|
||||
def build_jar
|
||||
`rm framework/local.properties`
|
||||
`rm framework/local.properties` if File.exists? 'framework/local.properties'
|
||||
`rm framework/phonegap.jar` if File.exists? 'framework/phonegap.jar'
|
||||
`rm framework/phonegap.js` if File.exists? 'framework/phonegap.js'
|
||||
`ECHO 'sdk-location=#{ @android_sdk_path }' > framework/local.properties`
|
||||
`ant jar`
|
||||
`cd framework; ant jar`
|
||||
end
|
||||
|
||||
# runs android create project
|
||||
# TODO need to allow more flexible SDK targetting
|
||||
# TODO validate Android SDK
|
||||
def create_android
|
||||
`android create project -t 5 -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
|
||||
end
|
||||
@ -42,10 +51,11 @@ class Build
|
||||
# - copy www/icon.png into #{ @path }/res/drawable/icon.png
|
||||
#
|
||||
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 framework/res #{ @path }/res`
|
||||
`cp framework/assets/www #{ @path }/assets/wwww`
|
||||
`cp -R framework/res #{ @path }/res`
|
||||
`cp -R example #{ @path }/assets/wwww`
|
||||
end
|
||||
|
||||
# this is so fucking unholy yet oddly beautiful
|
||||
@ -68,14 +78,17 @@ class Build
|
||||
}
|
||||
}
|
||||
"
|
||||
open("#{ @path }/src/#{ @pkg.gsub '.', '/' }",'w') { |f| f.puts j }
|
||||
dir = "#{ @path }/src/#{ @pkg.gsub '.', '/' }";
|
||||
cls = "#{ @name }.java"
|
||||
pth = File.join(dir,cls)
|
||||
open(pth,'w') { |f| f.puts j }
|
||||
end
|
||||
#
|
||||
end
|
||||
|
||||
|
||||
if(ARGV.length == 5)
|
||||
Build.new.start(ARGV)
|
||||
if ARGV.length == 5
|
||||
Build.new(*ARGV).run
|
||||
else
|
||||
puts <<-EOF
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.phonegap" android:versionName="1.1" android:versionCode="3">
|
||||
package="com.phonegap" android:versionName="1.1" android:versionCode="5">
|
||||
<supports-screens
|
||||
android:largeScreens="true"
|
||||
android:normalScreens="true"
|
||||
@ -38,6 +38,6 @@
|
||||
<action android:name="android.intent.action.PICK" />
|
||||
</activity>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="3" />
|
||||
<uses-sdk android:minSdkVersion="5" />
|
||||
|
||||
</manifest>
|
||||
|
@ -64,9 +64,9 @@
|
||||
assets directory -->
|
||||
|
||||
<target name="move_files">
|
||||
<concat destfile="assets/www/phonegap.js">
|
||||
<fileset dir="../js" includes="phonegap.js.base" />
|
||||
<fileset dir="../js" includes="*.js" />
|
||||
<concat destfile="../example/phonegap.js">
|
||||
<fileset dir="assets/js" includes="phonegap.js.base" />
|
||||
<fileset dir="assets/js" includes="*.js" />
|
||||
</concat>
|
||||
</target>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user