How To Add Parse to an Android Studio Project?

前端 未结 8 1676
野趣味
野趣味 2020-12-24 01:22

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 libr

相关标签:
8条回答
  • 2020-12-24 01:51

    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

    0 讨论(0)
  • 2020-12-24 02:00

    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!

    0 讨论(0)
  • 2020-12-24 02:00
    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!!
    0 讨论(0)
  • 2020-12-24 02:01

    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.

    0 讨论(0)
  • 2020-12-24 02:08

    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.

    0 讨论(0)
  • 2020-12-24 02:11

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

    0 讨论(0)
提交回复
热议问题