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 Build a Self-Destructing Message Android App Adding Users Using Parse.com Creating an Account and App on Parse.com

Inserting the Parse.com files in Android Studio

I've attempted to do many of the suggestions in this video to no avail. I have some significant errors that have occurred as a result. The manifest file mysteriously developing errors that were not there before.

I need to insert the parse jar file into the library but Android Studio doesn't have a lib file. How do I create this file. Each time I attempt to create it it shows up in the file folder in my computer but not in Android Studio. I've attempted rebuilding the project, syncing gradle, and ultimately restarting Android Studio.

Any help will be appreciated...

I believe whatever is effecting this code:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gotobluetegu.ribbet"
    android:versionCode="1"
    android:versionName="1.0" >

is what is causing the problems. http://schemas.android.com/apk/res/android , versionCode, and versionName are all coming up in red.

8 Answers

Hello James,

you need to go to directory (please ensure that in the left corner you click (to switch) to project folder view:

  1. app- > src -> main

  2. right click on the main folder and select create directory please write libs (you can write other name as soon as you will provide this in gradle file I please read below)

  3. please drag the parse file (parse-1.9.1.jar in my case) to the new directory you created in step 2

  4. please go to file build gradle and inside last section please paste exactly what you will find on the website parse.com

in my case I needed to paste:

    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar'

important*** in the second line you need to provide your directory path so if you called your directory libs and you created it inside folder src then your second line will look like this:

 compile fileTree(dir: 'src/main/libs', include: 'Parse-*.jar')

finaly my last section looks like this (please ensure that you will only add new two lines please do not remove any existing lines inside this section: (in my case first two lines were there already):

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'src/main/libs', include: 'Parse-*.jar')
}
  1. please press the button next on the left to AVD manager - button calls SyncProjectWithGradleFile

  2. after this is successful please create in folder java new class for example RibbitApplication

public class RibbitApplication extends Application {
    @Override
    public void onCreate() {

        // please copy here the lines from page parse.com in my case 
       //it was two lines please ensure that you will include them all
      //only in case you need them both
   }
}
  1. Please open manifest file and add in the section application following:
android:name="RibbitApplication"

and above application section:

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

the above will give permission to access network state on Andorid and Internet.

Please let me know in case you have any question to any step.

Cheers, Hubert

Thanks Hubert... I had continued working on the issue and just moved the libs file to the correct area and it fixed that part of the issue.

There is still an issue with the bottom portion (the code I posted is still red). I might attempt to start over and see if it clears up!

Sharan Soni
Sharan Soni
3,347 Points

Hubert, you are awesome!!! Thank you for the help.

Hi James, please can you send here entire gradle file code and manifest as well? Thanks, Hubert

For some odd reason I wake up and Android Studio is now accepting almost everything. The only issue is here android:label="@string/title_activity_signup" Which I'm assuming hasn't been setup.

Here is the code you requested.

Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "com.gotobluetegu.ribbet"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
}

Manifest File

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gotobluetegu.ribbet" >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:name= '.RibbetApplication'
        >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".LoginActivity"
            android:label="@string/title_activity_login"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name=".SignupActivity"
            android:label="@string/title_activity_signup"
            android:screenOrientation="portrait">
        </activity>
    </application>

</manifest>

Hi James not sure if I see correctly let's start from the manifest file please see below:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gotobluetegu.ribbet"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="22" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" android:name="com.gotobluetegu.ribbet.RibbitApplication">
        <activity
            android:name="com.gotobluetegu.ribbet.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.gotobluetegu.ribbet.LoginActivity"
            android:label="@string/title_activity_login"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.gotobluetegu.ribbet.SignUpActivity"
            android:label="@string/title_activity_signup"
            android:parentActivityName="com.gotobluetegu.ribbet.LoginActivity"
            android:screenOrientation="portrait" >
        </activity>
    </application>

</manifest>

please advise is that how the manifest file looks like on your end? (please check if I did not make any typos when naming your id activities labels etc)

Cheers, Hubert

Looks similar. There are a couple lines you have like "parentActivityName". I cleaned up the above formatting for readability.

Hi James that's ok I make few experiments on my with back button :)

ok let's go to the gradle file my looks like below:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.teamtreehouse.ribbit"
        minSdkVersion 14
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.1.0'


    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'src/main/libs', include: 'Parse-*.jar')
}

important I am using latest version of android studio but library for this project I took exactly the same which Ben is using. This should not impact your manifest as before I was using version 22 as well.

If this is like your gradle file look like please can you run SDK manager and ensure that you have latest bug fixes packages installed for 22? I remember at the beginning I had few issues as well. If this will not work we will do one other thing.

Please let me know. Cheers, Hubert

Hi James sorry I am blind where did you put in your manifest line with version? or you removed them due to this error you had?

  • your manifest is duplicated??? you cannot have two time manifest node - unless it was a forum copy issue.

It is only in Android Studio once... So I assume I pasted it twice.

<?xml version="1.0" encoding="utf-8"?> is on the top if that is what you meant.

ok. did you checked sdk? do u have any missing updates to 22 packages? you can do that by clicking SDK manager in top menu.

one more question before we will re import entire project. Please advise where is your parse .jar file? do you see it on the three?

I was missing the build tools for 22. So I'm downloading them now. There were a bunch of 21 api's that needed updating too. Hopefully that was the issue.

I'm just waiting on things to download and install.

The .jar file is not showing up in the tree on Android Studio. It is showing up in the file folder in Windows Explorer.

What I am finding out too is if I rebuild and/or clean the project errors occur. If I resync the Gradle it corrects the errors. It seems like some strange stuff going on with Android Studio.

Hi James great to hear there is some progress. What did was:

I created manually folder libs under src/main then I put this path when adjusted my gardle:

compile fileTree(dir: 'src/main/libs', include: 'Parse-*.jar')

path is very important so if you use as I did you have to see the parse jar in your tree folder (otherwise you need to use accordingly to your setup if you did the other way) How I transferred my jar?

Opened half screen Android Studio vs half screen windows explorer and drag and drop file in the newly created folder. Please let me know if it worked out.

Cheers, Hubert