39

I'm trying to use the Parse library in Android Studio. I have used the basic example on their website and added the jar to the libs folder as well as added as a global library. Nothing seems to be working without errors:

Gradle: package com.parse does not exist
Gradle: package com.parse does not exist
Gradle: package com.parse does not exist
Gradle: cannot find symbol variable Parse
Gradle: cannot find symbol variable ParseAnalytics
Gradle: cannot find symbol class ParseObject 
Gradle: cannot find symbol class ParseObject

Android Studio gives no errors in the code.

lschlessinger
  • 1,934
  • 3
  • 25
  • 47
ryebread761
  • 705
  • 1
  • 7
  • 14
  • maybe this help to you http://stackoverflow.com/questions/16601299/how-to-create-a-library-project-in-android-studio-and-an-application-project-tha?rq=1 – Robert May 18 '13 at 21:42
  • 1
    I don't make parse, I want to use it. Parse is made by parse, a company that was recently acquired by Facebook. – ryebread761 May 19 '13 at 04:51

8 Answers8

51

I encountered the same problem too and here's what I did:

  • I placed the entire Parse-1.2.5 in the libs folder (I didn't have to create the folder as Parse's quickstart said).
  • Open the build.grade file. There are two of them - open the one that's at the same level as the src folder
  • You'll see two instances of "dependencies". Add the following to the "dependencies" that is NOT nested under "buildscript":

    compile files('libs/Parse-1.2.5/Parse-1.2.5.jar')

If that still doesn't work, try right clicking the Parse-1.2.5.jar file and select "Add to Project Library"

Hope that helps!

quitePro
  • 546
  • 5
  • 3
  • 4
    Thanks, it compiles now. The app immediately stops unexpectedly though. It was just a blank app I added the quickstart parse stuff to, any ideas? – ryebread761 May 25 '13 at 02:49
  • Yup that's what I noticed as well. I tried configuring it to get it to work with Android Studio but failed. Maybe the Parse SDK isnt ready for Android Studio. I ended up creating a project in Eclipse, setting up Parse (it worked) then importing the project over to Android Studio so that I could use the IDE tools. Maybe marking my post as an answer? :) – quitePro May 25 '13 at 18:17
  • 2
    Why isn't this included in their quickstart guide? It seems like an important step ... – Logan May 13 '14 at 05:05
  • 4
    All i did was right click and said, "Add to Project Library" – horsejockey Sep 22 '14 at 16:24
  • 2
    This works! I wish Parse would update their crap and not force Android Studio users to scour the internet in order to use their software. – Johnny Oct 02 '14 at 06:52
  • i used the computer os to copy/paste parse sdk (Parse-1.7.0.jar) to 'app/libs' folder, then right click 'add to project library' (thanks horsejockey). – tmr Oct 14 '14 at 03:41
27

As of version 1.10.0 the Parse SDK is open source and available on Maven, so now you can just put this in gradle:

compile 'com.parse:parse-android:1.10.0'

Just replace 1.10.0 with whatever the newest verison is at the time you read this.

Alternatively, if you like living on the edge, you can tell gradle to auto-update:

compile 'com.parse:parse-android:1.+'

EDIT: On 1/28/16 Facebook announced that they are retiring the Parse service, so if you are starting a new project I would urge you to consider using a different service.

yuval
  • 6,369
  • 3
  • 32
  • 44
  • In my code it is failed to resolve :( ... I have imported eclipse project to android studio.. not able to resolve what the problem is ... – Charlie Sep 05 '15 at 17:11
  • @Charlie are you including the maven central repository in your gradle build file? If not, use this to add it: `repositories { mavenCentral() }` – yuval Sep 08 '15 at 17:49
  • 1
    Up to compile 'com.parse:parse-android:1.11.0' now and for noobs like myself don't forget to add to the Manifest! – AMAN77 Nov 13 '15 at 07:04
8

The problem is that gradle doesnt do a proper rebuild and somehow still reads a cached version of the old build script. Add the libs as per above reply then open a terminal and do a gradle clean. If you are running on windows (or any platform for that matter) I suggest you do a quick internet search on "intellij clean" to see what it does and then simply do a manual clean by deleting the appropriate folder. This should do the trick!

edit: before manually deleting the appropriate folders/caches you can also first try clicking on file -> invalidate caches. If this still doesnt work manually delete all the appropriate folders and caches

Chris
  • 4,593
  • 1
  • 33
  • 37
3

1) I unzip the folder into the libs folder:

YourProject/app/libs/Parse-1.9.2/ <<< here all the jar files.

2) and then in the dependencies section from your build.gradle, I set:

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

I set the specific folder where the jars are contained dir: 'libs/Parse-1.9.2'

Hope it helps!

Juan Saravia
  • 7,661
  • 6
  • 29
  • 41
2

In your app gradle add below code

dependencies {
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
}

In AndroidManifest.xml file add below permission

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

In your Application class inside onCreate() method add below code

Parse.initialize(this, "application_id", "client_key");
ParseInstallation.getCurrentInstallation().saveInBackground();

then run. Hope this works, for more info https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing

  • This worked for me! Except that now it should be ```implementation``` instead of ```compile```. Alternatively, just specifying the version I wanted works too: ```implementation 'com.parse.bolts:bolts-tasks:1.3.0' implementation 'com.parse.bolts:bolts-tasks:1.3.0'``` – ConcernedHobbit Jul 28 '19 at 23:51
0

Place the contents of the Parse-1.. folder in to your libs directory ... not the Parse-1.. folder itself. That worked for me.

user2220638
  • 1
  • 1
  • 6
0

donwload parse SDK for android and follow instruction given on below mentioned link: https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing

Add the SDK to your app in Android Studio Add the following to your build.gradle

dependencies {
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
}

and then

Add the following to your Application#onCreate():

Parse.initialize(new Parse.Configuration.Builder(myContext)
    .applicationId("YOUR_APP_ID")
    .server("http://YOUR_PARSE_SERVER:1337/parse")

    ...

    .build()
);

Your app must request the INTERNET and ACCESS_NETWORK_STATE permissions, if it isn't doing so already. Add the following lines inside the tag in your AndroidManifest.xml:

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

Compile and run!

After installing the SDK, copy and paste this code into your app, for example in your Activity#onCreate():

ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();

You will also have to add an import statement at the top of your file:

import com.parse.ParseObject;

Run your app. A new object of class TestObject will be sent to the Parse Server and saved.

Pravesh Tiwari
  • 147
  • 1
  • 6
0
  1. Unzip the Parse.zip file
  2. Go to Android Studio. Change Android to Project (top left corner).
  3. Expand the folders and find "libs".
  4. Copy the "parse" folder and paste it in the "libs".
  5. Now, under the "src" open build.gradle
  6. Paste the following under dependencies- compile files('libs/Parse-1.9.4/Parse-1.9.4.jar') compile files('libs/Parse-1.9.4/bolts-android-1.2.0.jar') (give your Parse version name)
  7. Done. You gotta ready to go!!
MJ019
  • 13
  • 1
  • 5