如何从github向android studio项目添加第三方库?

时间:2023-02-05 11:36:24

I want to use this library in my project.

我想在我的项目中使用这个库。

Github - AndroidCountryPicker

Github - AndroidCountryPicker

for other git libraries i always found the build gradle statement provided to be added to the project, here it is not. Can anyone help me? like these dependencies which i add to the project.

对于其他git库我总是发现提供的build gradle语句要添加到项目中,这里不是。谁能帮我?像我添加到项目中的这些依赖项。

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.easing:library:1.0.1@aar'
    compile 'com.github.clans:fab:1.4.0'
    compile 'com.daimajia.androidanimations:library:1.1.3@aar'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'it.neokree:MaterialTabs:0.11'
    compile 'it.sephiroth.android.library.floatingmenu:floatingmenu:1.0.1'
    compile 'com.github.castorflex.verticalviewpager:library:19.0.1'
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
    compile 'com.kbeanie:image-chooser-library:1.4.3@aar'
    compile 'org.jraf:android-switch-backport:1.4.0@aar'
    compile('com.doomonafireball.betterpickers:library:1.5.5') {
        exclude group: 'com.android.support', module: 'support-v4'
    }
    compile files('libs/easyandroidanimationslibrary-v0.5.jar')
    compile 'com.android.support:recyclerview-v7:21.0.3'
    compile files('libs/AndroidCountryPicker-master.jar')
}

If anyone could help me how to use the camera library would be great.

如果有人可以帮助我如何使用相机库将是伟大的。

1 个解决方案

#1


This library is build with Eclipse and doesn't provide a gradle support.

此库是使用Eclipse构建的,不提供gradle支持。

Also this lib has some resources, then you can use a jar file.

此lib也有一些资源,然后您可以使用jar文件。

Remove libs/AndroidCountryPicker-master.jar and remove this line from your build.gradle:

删除libs / AndroidCountryPicker-master.jar并从build.gradle中删除此行:

compile files('libs/AndroidCountryPicker-master.jar')

You have to:

你必须:

You should have somenthing like:

你应该像以下一样:

root:
      library1
        build.gradle
      app
        build.gradle
      settings.gradle
  • Change your settings.gradle file in

    更改您的settings.gradle文件

    include ':library1' include ':app'

    包含':library1'包含':app'

In your app/build.gradle file you have to add:

在app / build.gradle文件中,您必须添加:

dependencies {
    // Module Library
    compile project(':library1')
}

Finally in your library1/build.gradle you have to add something like this:

最后在library1 / build.gradle中你必须添加如下内容:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.1.3'
        }
    }
    apply plugin: 'com.android.application'


    android {
         lintOptions {
              abortOnError false
          }

        compileSdkVersion 22
        buildToolsVersion "22.0.1"

        defaultConfig {
          targetSdkVersion 22
        }

        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }              
        }
     }

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

#1


This library is build with Eclipse and doesn't provide a gradle support.

此库是使用Eclipse构建的,不提供gradle支持。

Also this lib has some resources, then you can use a jar file.

此lib也有一些资源,然后您可以使用jar文件。

Remove libs/AndroidCountryPicker-master.jar and remove this line from your build.gradle:

删除libs / AndroidCountryPicker-master.jar并从build.gradle中删除此行:

compile files('libs/AndroidCountryPicker-master.jar')

You have to:

你必须:

You should have somenthing like:

你应该像以下一样:

root:
      library1
        build.gradle
      app
        build.gradle
      settings.gradle
  • Change your settings.gradle file in

    更改您的settings.gradle文件

    include ':library1' include ':app'

    包含':library1'包含':app'

In your app/build.gradle file you have to add:

在app / build.gradle文件中,您必须添加:

dependencies {
    // Module Library
    compile project(':library1')
}

Finally in your library1/build.gradle you have to add something like this:

最后在library1 / build.gradle中你必须添加如下内容:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.1.3'
        }
    }
    apply plugin: 'com.android.application'


    android {
         lintOptions {
              abortOnError false
          }

        compileSdkVersion 22
        buildToolsVersion "22.0.1"

        defaultConfig {
          targetSdkVersion 22
        }

        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }              
        }
     }

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