How to Build PhoneGap Project with AndroidStudio In using Gradle Build

9:01:00 AM , 0 Comments

Recently phonegap & Android Studio has a new version of new building system (Gradle Build). many beginner developers don't know about this building system.for Example, who use android studio old Version like 1.00.

Old project Structure and new Gradle project structure are pretty different.Now time to need Maigret project in new building system in this system are easy. but the question is if you don't know this new build system than your not able to Maigret your old project to new Gradle build project.

Recently google announce to update google play service  in this update google user her all tools in one place and make developing apps with google tools very easy.

In this article, I will show native apps developing tools like PhoneGap project developing with an android studio in Gradle build.

If you have already created an application with PhoneGap . and now find to migrate old project in new gradle building project then this article is helpful to you.

Here I'm showing few easy step. if you try this step than you will be easily Maigret  your old project to a new building system.
So let's start
phonegap
To start first Please do this simple  
Update Android Studio for Latest version.
Update android SDK Tools Minimum 19.0.1 Installed
Install Google API (Android 4.2.2 17 ) via SDK tools
Install Google Play Service & Google Repository Vai SDK tools
Android SDK Build Tools 19.0.2
Build gradle 0.9.+ or  gradle-1.10-all
Download PhoneGap ( minimum 2.9.0 )
And Also Need to Install Java Development Kit JDK 1.7.0_45
Check Environment: 
If you have done this now Check your PC Environment Simple Flowing this Article Environment Setup Guide.
Now Let's Start.
Create a project. New Project > If you don't know how to see here this article How to create gradle build project in using android studio

Adding PhoneGap :

1.  Copy cordova-2.9.0.jar File And Past Into your libs/ folder . See Blow Image Details

phonegap

2. Now Copy [assets] [cordova] both folder from x:\yourlocation\phonegap-2.9.0\phonegap-2.9.0\lib\android\example means your downloading phonegap folder and past in to newly create project folder scr/ main Looking image 2

android studio
Phonegap-2.9.0  example project 

After Past, both folders your project show this 

In this image after past [assets] & [cordova] folder you android studio project will show now assets>www and cordova add in scr/main.

Save the changes and click Sync Project with Gradle Files  in the toolbar.

3.  Now I will need to add Config.xml file and this project. simple copy XML folder in \phonegap-2.9.0\lib\android\example\res\xml  and the past into nNew scr/main/reshere after pasting this your new res project directory look like


Save the changes and click Sync Project with Gradle Files  in the toolbar.
4.  Open up AndroidMainifest.xml file set flowing the permission line before the

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bijoy.appskhoj.apps">

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.RECORD_VIDEO"/>
    <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" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <activity android:name=".MainActivity"
            android:theme="@android:style/Theme.Black.NoTitleBar"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Activity google play service. -->
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />


    </application>



</manifest>

5. Now open up MainActivity.java the file in java remove old code and import by replacing new code. Past flowing code in your MainActivity.java file

package com.bijoy.appskhoj.apps;

import android.os.Bundle;
import android.widget.LinearLayout;
import org.apache.cordova.*;
import org.apache.cordova.DroidGap;

public class MainActivity extends DroidGap {
    /** The view to show the ad. */


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.init();
        super.loadUrl(Config.getStartUrl());
        super.loadUrl("file:///android_asset/www/index.html");

    }
}

Save the changes and click Sync Project with Gradle Files  in the toolbar.

Once you’ve completed all of the above you can hit the run button and have the application running whether on the Android Emulator or a device if you have one connected. Now you can start adding all sorts of crazy things to your boring HTML file and see it in action as a mobile app.


Google Play Service Setup :
Google Play Service Setup Guide See Here for Steep by Steep Setup Guide line Install The Google Play Services SDK In Android Studio

Abdullah Al Mahamud,

Abdullah Al Mahamud

Abdullah Al Mahamud is a programmer and founder of Thedevline an Inspiration blog since 2014. live in Bangladesh. , 28 years old.He is passionate about Technology and Design.He work on the freelancing marketplace as a freelancer and has also written for this blog.. Know more


Let's get connected with: Facebook Twitter Google+ Instagram

Content may not be re-published without permission.
Some pages on this site include affiliate links.

0 comments: