Import App into Android Studio
After CMS installation, please follow below given instructions to set up your mobile application..
4.1) – Getting Started
Download and install all latest tools, required for developing Android apps such as Java Development Kit and Android Studio as the Official Android IDE. For updated tutorial about how to install them, you can see and Download this from Android Developer website.
Download Android studio IDE
4.2) – Android Studio Setting
There are three main things interacting when you use Android Studio to create android applications.
· The code you write in Java or Kotlin to create interactive android apps
· Android Studio itself, an IDE that provides you with a nice interface for coding
· Android SDK, a selection of tools including the Android platform itself
Now you can click on Android Studio to launch it. Once it opens up, you’ll be presented with a menu where you’ll be able to get started or configure some options. The great thing is that everything is handled for you at this point, though you may want to familiarize yourself with the SDK Manager (Configure > SDK Manager) which is where you’ll update your Android SDK to support newer versions, as well as download things like code samples or support for Google Glass. But don’t worry about that now but if Android Studio says you’re missing something, this is where you’ll probably need to go to find it.
4.3) – Open up Project in Android Studio
Locate your Android app in the given project zip folder and extract it somewhere in your computer.
· Once Android studio ready, click open an existing android studio project.
· Browse to directory where you placed the android project and click OK after selecting the root directory of project.
While opening up the project you will get a popup like this. please click OK to building the project.
After this android studio will download some of the packages and execute some gradle plugins into your project
Note: this may take some time to compile.
While importing your android app you may get some dependencies errors. to resolve that you just need to update versions of libraries or dependencies.
After every thing is done. your android studio project will look like this. you may ignore the plugin update if it recommends that.
Note: if you want to update your gradle plugin that may need to change some deep source code. It is better to user the same version of plugin.
Project directory structure looks like this. your all java source code is placed under the following package.
we only need ConstantValues.java file to attach our backend.
ConstantValues file looks like this.
Setting Consumer Key & Secret Key
· Go to Admin Panel > Settings(Application) > Application API
· Click Generate to create your Consumer Key and Consumer Secret.
· Copy your Consumer Key and Consumer Secret.
· Open ConstantValues in android studio app
· Place your Backend URL, Consumer Key and Consumer Secret here.
Some Customization in Constants file
You can customize the following things from the ConstantValues file.
CODE_VERSION represents the code version of the android application.
IS_CLIENT_ACTIVE this boolean varaible toggle the demo feature. i.e. if it is false app will show all the home pages and categories in the app menu.
DEFAULT_NOTIFICATION this variable toggle in the cloud notification sdk. there are two sdk are integrate in the application. Onessignal and Firebase clooud messaaging
NAVIGATION_STYLE this variable represents the navigation style in the application. we have implemented two style if navigation which is Bottom Navigation and Side Navigation.
I don’t want to use AdMob
If you not want to use AdMob Just delete a number of lines from your code. Just follow the steps.
Step one:Open strings.xml file and remove this line.
“<!–AddMod AppID–><string name=”addmob_AppID” translatable=”false”>Your_AdMob id </string>”
Step two: Goto your manifest file and find this line and remove it.
“<meta-data android:name=”com.google.android.gms.ads.APPLICATION_ID” android:value=”@string/addmob_AppID”/>
Step three:Open ConstantValues.java file and find these lines and
then hold ctrl button on your keyboard and check where using these strings.
“public static boolean IS_ADMOBE_ENABLED;
public static String ADMOBE_ID;
public static String AD_UNIT_ID_BANNER;
public static String AD_UNIT_ID_INTERSTITIAL;”
Step Four: IS_ADMOBE_ENABLED uses in fourteen classes just go and remove the code where uses.
Name of classes:
Go one by one all the classes and remove the code. For example when you click About .java class this will take you go this code and just remove them
Step Five: ADMOB_ID uses in three classes just go and remove the code where uses.
Name of classes:
Step Six: Delete the uses of AD_UNIT_ID_BANNER from your code. AD_UNIT_ID_BANNER this is use in these classes and also shows in screen shots.
Step Seven: Delete the uses of AD_UNIT_ID_INTERSTITIAL from your code. AD_UNIT_ID_INTERSTITIAL this is use in these classes and also shows in screen shots.
I hope after following these steps your App run perfectly. Thank You
This link will take you to the Facebook Developer Console. After login with your Facebook account you will get a screen like this.
Enter your project name into the Edit Text Field and click Create New Facebook App ID. You will get a screen like this.
Skip that Import SDK Step and jump to Add SDK and copy that Facebook app ID and keep it safe.
In the Next step paste that application id and (application id)+.activities.SplashScreen and click Next.
In the next step you need to generate a key hash. keep in mind there are two methods for generating the developmental key hash and release key hash.
In order to generate the key hash first you need to download the OpenSSL tool. To download that for windows go to this link below.
Download OpenSSL tool compatible with your system and extract it to C:\OpenSSL.
Next you need to find the path of debug.keystore file in the C drive. usually it is placed in the C:\Users\YOUR_NAME\.android folder.
Now open the Command Prompt. and execute the following command.
For Debugging (use it for development purpose only.)
keytool -exportcert -alias androiddebugkey -keystore “C:\Users\YOUR_NAME\.android\debug.keystore” | “C:\OpenSSL\bin\openssl” sha1 -binary |”C:\OpenSSL\bin\openssl” base64
For Publishing use this command
keytool -exportcert -alias “aliasName” -keystore “keystoreFilePath” | openssl sha1 -binary | openssl base64
remember to change the path to you debug.keystore file. and make it sure to use the OpenSSL folder name same as you created in the C drive.
when you press enter this will get a password. If you do not create a new password, then default password will be android
This is your key hash save it to your file and use it in developer Facebook console.
Now paste the application key to the android studio project file shown below as “facebook_app_id”. (res > values > strings.xml)
Go to the above link and sign in with your Google account.
Now go to the Apps -> ADD APP as shown in the picture above.
In the next step you will get the App Id. save it to your notepad.
Then create a banner unit and Interstitial Unit and copy the add unity id for both, save it on your notepad.
Click below link to go to the Google admob documentation
Or simply paste this code into the Application tag in manifest file.
Replace YOUR_APP_ID with your unique ID in the android tag.
<!– Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 –>
Lets Say you want to change the android app package name from com.saudi.something to the com.saudi.newapp. to do that follow the steps given below.
⦁ First open the Project Structure window in the android studio project by pressing CTR+ALT+SHIFT+S and under the app -> Flavour tab change the application id to the new application package name and hit OK
⦁ Next go to the AndroidMenifest.xml file and change the application package name to the new one.
⦁ Next go to the Firebase Project and delete the previous app and create a new one with new android package name
⦁ to add new app to the Firebase Project click on android icon.
⦁ Next enter new credentials into the required fields.
⦁ to get the new SHA-1 key execute a file shown in the image bellow by double click on it.
⦁ copy the SHA-1 key from here.
⦁ and paste it in the Firebase Project here. and hit Register App.
⦁ Next download the google-services.xml file from here.
⦁ next change the android studio project view to the project.
⦁ and move the downloaded google-services.xml file here in the app directory as shown in the image bellow.
⦁ hit Overwrite button.
⦁ Next also change the package name in the google projects, google cloud platform to the new one.
⦁ also in the developer.facebook.com under the settings -> basic settings – > change the application id and application secret to the new one
⦁ after changing it to new one hit save changes.
⦁ Next in the android studio project change the Compact Middle Package view from the little gear button as shown in the picture bellow
⦁ and right click on the folder you want to rename and click Refactor -> Rename and change it to the new one. and hit OK
⦁ Next Click on Do Refactor if prompt.
⦁ Next also change some files from the res -> layout folder .
1 – homepage_1.xml
2 – homepage_2.xml
3 – news.xml
⦁ Finally click the build and rebuild the project.
Other Source Code Customization
Here is all the ui and resources files under the res package.
anim all the animations used in the activity transitions are placed here.
drawable folder contains all the media resources file like icons, logos and other stuff.
layout folder contains all the ui screens and layout files related to ui.
menu this folder contains the menu files like action bar menu and bottom navigation menu.
mipmap this folder contains the launcher icon for the application.
values folder contains all types of values like all the constant string, integers, pixels, dimension etc used in the project.
You are free to customize as you want you application.