PhoneGap Learning Notes-----phone3.4 Android Build-export jar pack (available everywhere)-and export plugins or add third-party plugins

Source: Internet
Author: User

http://blog.csdn.net/klx502/article/details/40617497

The link already shows how to create a phonegap project from the command line

The theme is based on the previous "PhoneGap Learning notes-----phone3.4 android Build" extension.

1. Create the project:

2. Add platform support for the created directory:

3.build This project, you can then import the Android project in Eclipse:

4. In Eclipse, import the project:

5. Find the directory path you want when you created the first step, and you can look back at the first picture:


6. Add plugins from the official website:

Command line:

More plugins, Access: Click to open link


After adding the plugin you want, go back to Eclipse and refresh the project:


At this point, the online construction is over, followed by the export of PhoneGap 3.4 package and plug-in package after the work:



---------------------------------------------------------------------------------Split Line------------------------------------- ----------------------------


7. Export the PhoneGap package:

eclipse--Project List---Right-click--export:



8. Export the Downloaded plugin:

Of course, download the plugin here, you can download all of your own desired re-export, so as to avoid frequent export import

Now, get two packages, one is PhoneGap 3.4 package, one is a plug-in package, these two packages can be casually quoted, want to PhoneGap 2.9.1 that can be imported into the Android project.


9. One more step: (Show Assets files)

You will find that just used the command line to build the PhoneGap project, under the Assets folder, there is no www folder, there is no corresponding JS

The steps are:

Right-click project name----properties-> properties, Resource, Resource Filters

Remove these two items, and then determine


And then found that these are assets under the WWW show out



10: Create a new Android project:

Eclipse--new A new Android project (how to build an Android project in the usual way)

Import just two jar packages

Then create a new assets directory and copy the WWW folder that you just displayed to the assets directory:

Then add permissions for the project Androidmanifest.xml:

    <uses-permission android:name= "Android.permission.CAMERA"/> <uses-permission android:name= "Android.permi Ssion. Vibrate "/> <uses-permission android:name=" Android.permission.ACCESS_COARSE_LOCATION "/> <uses-permissi On android:name= "Android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name= " Android.permission.ACCESS_LOCATION_EXTRA_COMMANDS "/> <uses-permission android:name=" Android.permission.READ_PHONE_STATE "/> <uses-permission android:name=" Android.permission.INTERNET "/> &lt ; uses-permission android:name= "Android.permission.RECEIVE_SMS"/> <uses-permission android:name= " Android.permission.RECORD_AUDIO "/> <uses-permission android:name=" Android.permission.MODIFY_AUDIO_SETTINGS "/> <uses-permission android:name=" Android.permission.READ_CONTACTS "/> <uses-permission android:name=" Android.permission.WRITE_CONTACTS "/> <uses-permission android:name=" Android.permisSion. Write_external_storage "/> <uses-permission android:name=" Android.permission.ACCESS_NETWORK_STATE "/> < Uses-permission android:name= "Android.permission.GET_ACCOUNTS"/> <uses-permission android:name= " Android.permission.BROADCAST_STICKY "/>
Add in Activity.java:

TODO auto-generated Method Stubsuper.oncreate (savedinstancestate); Super.setbooleanproperty ("Loadinwebview", True ); Super.loadurl (Config.getstarturl (), 10000);//Load Application Home appview.getsettings (). Setjavascriptenabled (true);// Set support JavaScript script//loadurl (launchurl);
Right-click Project, Run as ... The project

At this point, the PHONEGAP project was created successfully.

11. Add a third-party plugin:


Locate Cordova_plugins.js Open in A.exports add:



Add on Module.exports.metadata:

Of course, you also need to import some Java classes from your third party, or jar packages

Finally, you will need to add the plug-in name reference in config:


Then you can quote the plugin you want in JS:



JS Call Java Method: Write a Java class, in JS call


Then, add the path to the class in config:

Then in JS, the method call to this Java class:


Methods of the Java class:



At this point, the reference to a third-party plug-in has ended. Limited level, Intern

PhoneGap Learning Notes-----phone3.4 Android Build-export jar pack (available everywhere)-and export plugins or add third-party plugins

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.