In this tutorial we will learn How to Convert a Website into Android Application using Android Studio
So lets create a project.
Step 1 – Create new Android project.
Provide Activity name as EasyOnlineConverter
Step 2 – Add an webView to your activity as shown in the picture below.
layout/activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <WebView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/webView" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /> </RelativeLayout>
src/main/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.programmingknowledge.easyonlineconverter" > <uses-permission android:name="android.permission.INTERNET"></uses-permission> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
MainActivity.java
package com.example.programmingknowledge.easyonlineconverter; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends ActionBarActivity { private WebView myWebView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myWebView = (WebView)findViewById(R.id.webView); WebSettings webSettings = myWebView.getSettings(); webSettings.setJavaScriptEnabled(true); myWebView.loadUrl("http://www.easyonlineconverter.com"); myWebView.setWebViewClient(new WebViewClient()); } @Override public void onBackPressed() { if(myWebView.canGoBack()) { myWebView.goBack(); } else { super.onBackPressed(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }
menu/menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"> <item android:id="@+id/action_settings" android:title="@string/action_settings" android:orderInCategory="100" app:showAsAction="never" /> </menu>
OUTPUT
Now run your android app, and you will see the following result
Click the button below to Download Source code
Download Source Code
Video Instructions
Good job but if it has any viedo in website it is not working why
thanks
Click the button below to Download Source code
Good job but if it has any viedo in website it is not working why
thanks
import android.view.MenuItem;
Thank you. It was very helpful. how can we view In Desktop view from the android app.. now it is automatically changed to mobile version when we access the URL from app
Thank You…..very helpful
Nice descriptive and very helpful.
how to copy and paste this code in android studio
These Errors Took Place While Creating APK :
Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
C:UsersuserDesktopandroid projectCrimeHack2appsrcmainjavacomexampleusercrimehackMainActivity.java
Error:(4, 37) error: package android.support.design.widget does not exist
Error:(5, 37) error: package android.support.design.widget does not exist
Error:(42, 36) error: cannot find symbol variable menu
Error:(54, 23) error: cannot find symbol variable action_settings
Error:Execution failed for task ‘:app:compileDebugJavaWithJavac’.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 39.347 secs
Information:5 errors
Information:0 warnings
Information:See complete output in console
I can’t able to download pdf files on this webview app. pls help
same problem with me please help..
is wrond. i put you code. for the test
i just copy and past you code but is don’ https://uploads.disquscdn.com/images/433e7f19593d9edf7f30faf3dbb5d2d5158557b4bd23ab74a7908a476bd5f873.jpg t workin’
How did you resolve that error code?
the line… myWebView = (WebView)findViewById(R.id.webView);
webView is an error
How did you resolve that error message?
Like a silly Noob I am, I forgot to input the below line in the activity_main.xml
android:id=”@+id/webView” *aka I didn’t name Webview
replace with this
myWebView = (WebView)findViewById(R.id.activity_main_webview);
I replace with this line but still getting error
How to resolve it?
https://uploads.disquscdn.com/images/821640dd24a26d7d837eccf1490b6e7e4b58f329167d96d33b6ffe73e4d9074b.jpg
okay baby
hahaha
Very nice n clear tutorial, thank you very much
how to use call service when we convert website to mobile app
and how to add admob adds code like banner ad video adds etc please help us
Error:Failed to capture snapshot of output files for task ‘transformClassesWithDexForDebug’ property ‘streamOutputFolder’ during up-to-date check.
> Failed to create MD5 hash for file ‘C:UsersAdminAndroidStudioProjectsEasyOnlineConverterappbuildintermediatestransformsdexdebugfolders10005slice_8classes.dex’.
What type of this issue? How to resolve?
many issues mostly appcompact library issue. Could you start wiith install, SDK to be installed & library dependencies ????
hi thank you for your guide it was really helpful.
I have a question and I be glade if you can help me.
I convert a website that have a login screen how can I auto fill this fields and submit ?
https://uploads.disquscdn.com/images/f026e9fa86c179462af356e60270c4879bcb5758d7fe4807e7834e06f939e17d.png
Mohammed did you solve the problem it should say myWebView, the name he gave at the top. I also have/had this problem.
Very good and thank for sharing
Very good tutorial, thanks for sharing,
i did like you wrote but errors appear!!! any body help?
i just created an app as told to convert web to app. and created my first ever APK file and run in my phone.
Only problem till now I found out that is when i click shopping cart in Website it says “the item being added to your shopping cart. However, in the app it does not show that popup though it adds the item in my shopping cart.
What should i do? What changes I need to make in my App.
Also I would like to change the APP Icon that is should show the Icon I want for my APP in the mobile. What do i need to do to change that icon?
Is it possible to update the android app. if it is possible, how can it be done since it was a website that was converted into an apk file. thanks
The version of Android Studio I downloaded appears to be an updated one, and a number of things are different. When I attempted to paste the code in the appropriate sections, it does not run the app, and gives errors at different points. Is there an updated version of the instructions?
Great Article, can you please share the steps for IOS apk also
Pretty sweet quick and easy guide! I’ve got a similar (slightly more in-depth) guide on converting your website into an app here https://christopherwd.com/how-to-convert-website-into-android-app/ – even includes setting up push notifications!
Cheers
Are all the APIs available (localStorage, fetch, …) ?
I was trying to do the same on new android studio, I think its not working anymore.
its cant connect websit after successful build
https://uploads.disquscdn.com/images/4923e411690d21c3d278223abb097e3f0823d482c0879a506fb186906c9c167b.png
how to creat apk file now?