dave
dave

Reputation: 575

Adding Parse-1.8.0 to Android Studio 1.0.1 (Or any .zip file)

So there seems to be a few threads that attempt to explain how to add .zip files to android studio but I am making no progress. I am migrating from eclipse so perhaps that is why I am so incompetent in figuring out how to perform this task. Can someone please explain how to add external libraries to Android Studio v1.0.1? In eclipse it was simply importing jar/zip and done.

Upvotes: 4

Views: 1904

Answers (3)

Thiago
Thiago

Reputation: 13302

This is the only way it worked for me :

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    //Parse
    compile 'com.parse.bolts:bolts-android:1.+'
    compile files('libs/Parse-1.9.2/Parse-1.9.2.jar')
    compile files('libs/Parse-1.9.2/ParseCrashReporting-1.9.2.jar')
    compile files('libs/Parse-1.9.2/ParseFacebookUtilsV3-1.9.2.jar')
    compile files('libs/Parse-1.9.2/ParseFacebookUtilsV4-1.9.2.jar')
    compile files('libs/Parse-1.9.2/bolts-android-1.2.0-javadoc.jar')
    compile files('libs/Parse-1.9.2/bolts-android-1.2.0.jar')
}

OR

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

Upvotes: 0

redVaryant
redVaryant

Reputation: 70

I was in the same situation, trying to integrate Parse 1.8 with Android Studio 1.0.2.

On Parse's instruction page, it simply tells you to import the library into Android studio, which isn't too detailed. Here is how I solved this problem.

  1. Choose to import from a "Non Android Studio Project", right when Android Studio starts.
  2. When it asks you to choose the project, give the path, on Windows e.g.C:/path/to/parsesdk/. On *nix systems, it should be to where you have extracted to it, /home/user/path/to/parsesdk.
  3. After you choose the path, Android Studio will import the project accordingly.
  4. Click on the Application root folder (the top most folder in the folder hierarchy to the left), right click > New > Package > and add it under the src folder, name is libs.
  5. Copy paste the jar to the libs folder (I only copied the jar file, as I didn't need the other extra material)
  6. Right click on the jar, there should be an option labeled as "Add as library" towards the bottom, click on that.

Android Studio will automatically add the following to the build.gradle file.

compile files('src/libs/Parse-1.8.0.jar')
  1. Once the above step is completed, click on File > Project Structure. On the left, there should be a section called "Modules", click on the "Dependencies" tab on the top.
  2. Click the green "+" sign > Module Dependency
  3. Select the module from the list.

Last thing, in the build.gradle file for the "ParseStarterProject" module, if there is a red line under the classpath, change it to the following

 dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0'
}

After completing this step, I was able to successfully build the app.

Hope this helps :)

Upvotes: 4

Amio.io
Amio.io

Reputation: 21575

If you are using gradle with android studio (which is the preferred way now) you can include jars in a folder using this code snipet from my build.gradle.

buildscript {
    repositories {
       flatDir { dirs 'c:\\path\\to\\folder' }
       mavenCentral()
    }
}

Or by including a single file in depencies like below.

dependencies {
    compile fileTree(dir: 'a-folder-in-root-of-project', include: 'a_jar.jar')
}

Upvotes: 0

Related Questions