简体   繁体   中英

build.gradle dependencies in android studio

I am developing an app using SQLiteAssetsHelper in Android studio and I have seen two build.gradle files. one is in the app folder and second is in folder, in my (project's name) folder the build.gradle file contains folowing

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.1.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

allprojects {
repositories {
    jcenter()
  }
}

but i saw most examples with mavenCentral() in repositories .. what should I have to do in this build.gradle file??.. second build.gradle file in app folder contains the following..

     apply plugin: 'com.android.application'

    android {
       compileSdkVersion 22
       buildToolsVersion "21.1.2"

   defaultConfig {
       applicationId "com.appxone.practicesqliteassetshelper"
       minSdkVersion 8
       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'
      }

in github they said to use

compile `com.readystatesoftware.sqliteasset:sqliteassethelper:+`

in dependecies and to use add jar file of sqliteassetshelper in lib folder.. but im totally confuse in which build.gradle , which dependencies i have to add this compile com.readystatesoftware.sqliteasset:sqliteassetshelper:+ statement.. and do i change the jcenter() into mavenCentral() .. i have used SQLiteOpenHelper class but this give only bunch of codes..and stackflow give me suggestion to use SQLiteAssetsHelper ..please help me I make an assets/databases/myDB.db as well but now what should i do next..

You need to add

compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'

into your module build.gradle file (usually it's called "app"), not in the top-level build file. So your module build.gradle should look like this:

 apply plugin: 'com.android.application'

    android {
       compileSdkVersion 22
       buildToolsVersion "21.1.2"

   defaultConfig {
       applicationId "com.appxone.practicesqliteassetshelper"
       minSdkVersion 8
       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.readystatesoftware.sqliteasset:sqliteassethelper:+'
  }

EDIT : Also, you should change buildToolsVersion "21.1.2" to buildToolsVersion "22.0.1" , but I'd suggest you to use buildToolsVersion "23.0.1" along with targetSdkVersion 23 and com.android.support:appcompat-v7:23.0.1 to support latest Android version.

There are two gradle files. 1st is build.gradle (Project Foo) and the other is build.gradle (Module : App) . Do not dare edit the 1st one.

Add it here:

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

make changes to app:gradle file

Replace your from:

buildToolsVersion "21.1.2"

To this:

buildToolsVersion "22.0.1"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM