Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Using Parse.com as the Backend for an Android App

error when renaming project

i was having a lot of trouble importing gradle into an existing project, so I attempted to use the parse-starter-project and just rename it, but when I tried to rename it 'Alerta', it changed the name of the root directory to "Alerta-Alerta". How can I make it just Alerta?

1 Answer

Hi, To import parse into an existing project follow the instructions below. If you are sure you did everything correctly please share your error.

Add these to your build.gradle(Module:app)

dependecies {
    ...
    compile 'com.parse.bolts:bolts-android:1.3.0'
    compile 'com.parse:parse-android:1.12.0'
}

Copy these to AndroidManifest.xml just before the application tag

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Create a java class, name it whatever you want. It must extend Application class

Your onCreate method should contain the following codes.

public class MyParseApplicationClass extends Application // <-- extend Application
{
    @Override
    public void onCreate() {
        super.onCreate();

        // Enable Local Datastore.
        Parse.enableLocalDatastore(this);

        // Add your initialization code here
        Parse.initialize(this);

        ParseACL defaultACL = new ParseACL();
        // Optionally enable public read access.
        // defaultACL.setPublicReadAccess(true);
        ParseACL.setDefaultACL(defaultACL, true);
    }
}

In line 6, write the name of your application class.

To add your metadata to AndroidManifest.xml,

In line 10, paste your application id between " ".

In line 13, paste your client key. You can get your application id and client key from Parse Quickstart guide after log in.

https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:name=".MyParseApplicationClass" -- Line 6 --
        android:theme="@style/AppTheme">
        <meta-data
            android:name="com.parse.APPLICATION_ID" -- Don't change this --
            android:value="YOUR_APPLICATION_ID"/> <!-- Line 10 -->
        <meta-data
            android:name="com.parse.CLIENT_KEY" -- Don't change this either --
            android:value="YOUR_CLIENT_KEY"/> <!-- Line 13 -->

it works. thank you very muchly.