Jumat, 26 Oktober 2018

Gradle 28

Settingan Gradle terbaru:

APP

apply plugin: 'com.android.application'
android {
    compileSdkVersion 28    defaultConfig {
        multiDexEnabled true        applicationId "com.example.komunitas"        minSdkVersion 15        targetSdkVersion 28        versionCode 1        versionName "1.0"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    }
    buildTypes {
        release {
            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }
    }
    useLibrary 'org.apache.http.legacy'}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:support-v4:28.0.0'    implementation 'com.android.support:appcompat-v7:28.0.0'    implementation 'com.android.support:recyclerview-v7:28.0.0'    implementation 'com.android.support:cardview-v7:28.0.0'    implementation 'com.android.support.constraint:constraint-layout:1.1.3'    testImplementation 'junit:junit:4.12'    androidTestImplementation 'com.android.support.test:runner:1.0.2'    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'    implementation 'com.google.android.gms:play-services:4.0.30'    implementation 'com.android.support:design:28.0.0'    implementation 'com.android.support:multidex:1.0.1'    implementation 'com.jjoe64:graphview:4.2.2'

}


Project

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'        
        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}



+++++++++++++++++++++++++++
YAITU:
Add multiDexEnabled true to your build.gradle
android {
    compileSdkVersion 26
    defaultConfig {
      ...
        minSdkVersion 15
        targetSdkVersion 26
        multiDexEnabled true
     ...
    }
}
and add the dependency
dependencies {
    compile 'com.android.support:multidex:1.0.1'}
It may the first one works for u and so on but it really depends on the nature of your problem for me for example
I got the error once I have added this library
implementation 'com.jjoe64:graphview:4.2.2'
and later I discovered that I have to check that and I have to add the same version of the support libraries. So I have to try another version
compile 'com.jjoe64:graphview:4.2.1'
and it fixes the problem
it's better to use implementation or api rather compile
just replace compile with implementationdebugCompile with debugImplementationtestCompile with testImplementation and androidtestcompile with androidTestImplementation
For example: Instead of this
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.github.bumptech.glide:glide:4.0.0'
use like this
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
SO:
  • Delete all the build folders and the gradle cache.
  • From the Build menu, press the Clean Project button.
  • After task completed, press the Rebuild Project button from the Build menu.




Tidak ada komentar:

Posting Komentar