How to open a downloaded project in Android Studio

keyboard_arrow_left Back to the overview

Install Android Studio

Go to the Download page and download the package for your OS.

Unpack the downloaded file to a destination of your choice, then follow the instructions described in Install-Linux-tar.txt file which is in the extracted folder.

Prepare a project file

Open a shell and navigate to the root folder of your Android sources, e.g. ~/android/lineage. In case environment functions and variables are not yet loaded, type:

Now execute:

make idegen && development/tools/idegen/idegen.sh

In case you are developing on multiple branches or plan to do so (otherwise skip the next step), do the following (replace every occurrence of lineage with your desired naming scheme):

mv android.ipr lineage.ipr
mv android.iml lineage.iml && ln -s lineage.iml android.iml

Prepare Android Studio

Android Studio struggles to parse the huge LineageOS / Android sources and requires some different settings than the defaults. Therefore, before starting actual development, it is necessary to change some of those.

Configure memory

Open Android Studio and click on Configure.

Then click on “Edit Custom VM Options” and include the following:

This will set the initial allocated (Xms parameter) and maximum usable (Xmx parameter) RAM to 748MB each. You can also use higher numbers but should not go below that to ensure usability. You can find more information of these and other parameters in the official documentation

Increase the file parsing limit

Again, click on Configure and then click on “Edit Custom Properties” and put idea.max.intellisense.filesize=5000 there (you can change its value to something higher than 5000, if you wish)

This is required so Android Studio can parse very large files to properly provide the auto-complete features (Android Studio calls this IntelliSense).

Start working with Android Studio

Reopen Android Studio and click on Open existing project.

Then navigate to your Android source directory and open the .ipr file.

Configure the project

After opening the project, navigate to File -> Project Structure -> SDKs (this might be disabled until the indexing has finished) and set up a JDK (version 1.8 for LineageOS 14.1 branch) where you remove all libraries (.jar files).

Then, on the left side of the settings panel, choose Project Settings -> Modules and mark the folder out/target/common/R as Sources (you can also select it and press [ALT]+[S]).

Press Apply and close the settings.

Start developing

Now, after all the previous steps are done, you can actually start developing and exploring the sources. The Find in path function (Edit -> Find -> Find in path) can be a good start to find a file you want to modify. Just search for a known string among all source files and then dive in deeper until you actually found the function you want to modify.

Contribute!

After you have modified the sources and tested your change, you can contribute to LineageOS by submitting your work.

Download an Android project with source code and start using Back4App

Introduction

In this guide, you will learn how to get started with an Android application written in Java or Kotlin and connect it to Back4App.

If you want a detailed Quickstart guide or connect Back4App to an existing project, go to our Install Parse SDK tutorial

Goal

Download an Android Template and connect it to Back4App

Prerequisites

  • Android Studio version 4.1 or newer.
  • An app created at Back4App.
    • Follow the New Parse App tutorial to learn how to create a Parse app at Back4App.

Step 1 - Download the template

There are 2 Android templates, one written in Java and the other on Kotlin:

  • Kotlin Example Repository
  • Java Example Repository

Choose the template that suits you, and proceed to download or import your project on Android Studio. Android Studio.

Step 1.1 - Download Directly from GitHub

Use the following commands to download and unzip your project template:

  • MacOS and Linux
  • Windows

How to open a downloaded project in Android Studio

  • Java
  • Kotlin

$ curl -LOk https://github.com/templates-back4app/android-java-starter-template/archive/master.zip && unzip master.zip

$ curl -LOk https://github.com/templates-back4app/android-kotlin-starter-template/archive/master.zip && unzip master.zip

Step 1.2 - Open the project on Android Studio

After downloading the files, unzip them. Let’s open Android Studio

In the welcoming screen of Android Studio, choose ‘Open an Existing Project’ and select the project’s folder.

How to open a downloaded project in Android Studio

Choose your downloaded and unzipped folder’s location and open it.

Please wait until the finish of the Gradle Run process. Now you can see Gradle console bottom tabs in Android Studio.

Step 1.3 - Import from GitHub(Optional Path)

You can import the repository link directly to Android Studio. On Android Studio welcoming screen, choose ‘Get from Version Control’

How to open a downloaded project in Android Studio

Android Studio will ask you for the Git repository link and the desired project path. You can find repository links at the start of this section.

You can find repository links in the start of this section

How to open a downloaded project in Android Studio

After filling the URL and Directory fields, click on the Clone button. Then Android Studio will copy and open the project for you. Please wait until the finish of the Gradle Run process. Now you can see Gradle console bottom tabs in Android Studio

Android Studio will copy and open project for you

Please wait until gradle run is finished.You can see gradle console bottom tabs in Android Studio

Step 2 - Get your App Keys

In this guide we will use following files in project :

AndroidManifest.xml - We will set our Back4App credentials as <meta-data> and app permissions
App.java (App.kt for kotlin) - We will modify our initialization code in here
MainActivity.java (MainActivity.kt for kotlin) - Will contain our very first code for creating a Parse Object
strings.xml - We will store and read Back4App setup credentails from here
build.gradle - We will set our Parse Android SDK version in here

In order to connect your App project to Back4App’s server, you’ll need three primary information the server URL, the Application ID, and the Client Key.
In an Android project, strings.xml is a perfect place to set this information. It is where Parse Android SDK reads Application key values to make a connection with your Back4App App.
The server URL is already on the project. You’‘ll need now go to Back4App, copy your App keys, and update your strings.xml with those values:

  1. Open your strings file: .../app/src/main/res/values/strings.xml

    How to open a downloaded project in Android Studio

  2. Go to your App Dashboard at Back4App Website.

  3. Find you keys on: App Settings > Security & Keys.

    How to open a downloaded project in Android Studio

  4. Return to your strings.xml file and paste your applicationId and clientKey.

    1
    2
    3
    4
    5
    6
    7
    8
    
     <resources>
         <string name="app_name">Back4AppExample</string>
         <string name="back4app_server_url" translatable="false">https://parseapi.back4app.com/</string>
            
         <!-- Paste BOTH keys here  -->
         <string name="back4app_app_id" translatable="false">PASTE_YOUR_APPLICATION_ID_HERE</string>
         <string name="back4app_client_key" translatable="false">PASTE_YOUR_CLIENT_KEY_HERE</string>
     </resources>
    

  5. Open your build.gradle (Module:Back4AppExample.app) file in Gradle Scripts from Project Explorer

    How to open a downloaded project in Android Studio

    In dependencies section change the Parse-SDK-Android value with version of your choice.

    1
    
         implementation "com.github.parse-community.Parse-SDK-Android:parse:latest-version-here"
    

    After saving build.gradle run ‘Sync Now’

You can see current version of SDK in here SDK Versions.

Step 3 - Connect to Back4App

After setting up your App credentials, you are ready to connect with your Parse Server instance on Back4App.

This is the initialization code you’re going to use:

You can reach initialization code in project in App.java (App.kt for kotlin)

We are using App.java for our initialization because we need to establish connection before app takes any other action. App.java is the first Context to be created before any other Activity and Service and last to be destroyed.

Below initilization code gets App Keys from strings.xml and try to establish a connection with our Back4App server. We put our code onCreate() method because we want to connect to our server first before taking any other action.

  • Java
  • Kotlin

app > java > com > back4app > java > example > App.java

1
2
3
4
5
6
7
8
9
10
11
public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Parse.initialize(new Parse.Configuration.Builder(this)
                .applicationId(getString(R.string.back4app_app_id))
                .clientKey(getString(R.string.back4app_client_key))
                .server(getString(R.string.back4app_server_url))
                .build());
    }
}

app > java > com > back4app > java > back4appexample > App.kt

1
2
3
4
5
6
7
8
9
10
11
class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Parse.initialize(
            Parse.Configuration.Builder(this)
                    .applicationId(getString(R.string.back4app_app_id))
                    .clientKey(getString(R.string.back4app_client_key))
                    .server(getString(R.string.back4app_server_url))
                    .build());
    }
}

Now it is time to add some codes for interacting with the server. Let’s open our MainActivity file.

Activity files are great for interacting with user. They are main purpose providing a User Interface.

You can choose which activity to show in launch in AndroidManifest.xml

1
2
3
4
5
6
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

In our project MainActivity is set to open on launch.

In this code sample we have a Parse SDK code for saving a Parse Object to server and showing objectId of saved Parse Object to user with a TextView

  • Java
  • Kotlin

app > java > com > back4app > java > example > MainActivity.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView textView = findViewById(R.id.textView);
        ParseObject firstObject = new  ParseObject("FirstClass");
        firstObject.put("message","Hey ! First message from android. Parse is now connected");
        firstObject.saveInBackground(e -> {
            if (e != null){
                Log.e("MainActivity", e.getLocalizedMessage());
            }else{
                Log.d("MainActivity","Object saved.");
                textView.setText(String.format("Object saved. %s", firstObject.getObjectId()));
            }
        });
    }
}

app > java > com > back4app > kotlin > back4appexample > MainActivity.kt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val textView = findViewById<TextView>(R.id.textView)
        val firstObject = ParseObject("FirstClass")
        firstObject.put("message","Hey ! First message from android. Parse is now connected")
        firstObject.saveInBackground {
            if (it != null){
                it.localizedMessage?.let { message -> Log.e("MainActivity", message) }
            }else{
                Log.d("MainActivity","Object saved.")
                textView.text = String.format("Object saved. %s", firstObject.objectId)
            }
        }
    }
}

Step 4 - Test the connection

  1. Build your app in a device or virtual device (Shift+F10).

    How to open a downloaded project in Android Studio

If you don’t have any virtual device to run app. You can create a new one from AVD Manager in Android Studio

  1. Wait until the Hello Word! screen appears. After Hello Word! you will see Object saved. Message this message will include saved object’s id.

    How to open a downloaded project in Android Studio

  2. Login at Back4App Website.
  3. Find your app and click on Dashboard > Database > Browser.

If everything works properly, you should find a class named FirstClass as follows:

How to open a downloaded project in Android Studio

It’s done!

You can see objectId in dashboard and your app’s screen is matches !

At this point, you have learned how to get started with Android apps.

Learn more by walking around our Android Tutorials or check Parse open source documentation for Android SDK.

Where are my projects in Android Studio?

Android Studio stores the projects by default in the home folder of the user under AndroidStudioProjects.

How can I open RAR File in Android Studio?

Follow the below instructions to open a RAR file on your Android device:.
Download and install the RAR app for Android..
Open the RAR app. ... .
Navigate to the folder containing the file you wish to open. ... .
Tap the RAR file and enter the password, if prompted, to view the contents. ... .
Tap the individual files to open them..