Moon Light Box

Time is Money

Posts match “ gradle ” tag:

Android - Warning:Conflict with dependency 'com.android.support:support-annotations'.

| Comments

We use gradle to import libraries. And it will cause dependency problem.

Gradle build error message:

Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (20.0.0) and test app (22.0.0) differ.

Solution:

Add below configure in build.gradle file.

allprojects {
    ...
    configurations.all {
        resolutionStrategy.force 'com.android.support:support-annotations:23.0.0'
    }
    ...
}

Reference:http://code.google.com/p/android-test-kit/issues/detail?id=136
Reference:https://github.com/googlesamples/android-testing/issues/22

Android - finished with non-zero exit value 3

| Comments

Gradle build error message:

When your Android project contains too many class, Android Studio will throw non-zero exit value 3 during dex apk period.

Error:org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_67\bin\java.exe'' finished with non-zero exit value 3

Solution:

Add below configure in build.gradle file.

dexOptions {
    javaMaxHeapSize "4g"
}

Reference:http://stackoverflow.com/questions/31605291

Android - Volley Build Failed in Android SDK 23

| Comments

Apache HTTP Client Removal start from Android SDK 23. So we have to add they back manually.

The org.apache.http.legacy.jar is in Android/sdk/platforms/android-23/optional and copy it to your Android project. For exmple, libs folder.

1. Modified build.gradle file with below changes.

dependency {
    compile project('libs/org.apache.http.legacy.jar')
}

or

android {
    useLibrary 'org.apache.http.legacy'
}

2. Modified proguard files.

Warning:library class org.apache.http.conn.scheme.LayeredSocketFactory extends or implements program class org.apache.http.conn.scheme.SocketFactory
Warning:library class android.webkit.WebView depends on program class android.net.http.SslCertificate
Warning:library class android.webkit.WebViewClient depends on program class android.net.http.SslError
Warning:library class org.apache.http.params.HttpConnectionParams depends on program class org.apache.http.params.HttpParams
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-dontwarn android.net.**

Reference:https://github.com/mcxiaoke/android-volley/issues/92
Reference:http://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client

Linux - Install Gradle in CentOS 7

| Comments

Step 1. Download and Install Gradle.

# cd /opt
# sudo wget https://services.gradle.org/distributions/gradle-3.1-bin.zip
# sudo unzip gradle-3.1-bin.zip
# sudo ln -s gradle-3.1 gradle

Step 2. Set Gradle Environment Value.

# sudo vim /etc/profile.d/gradle-env.sh

export GRADLE_HOME=/opt/gradle
export PATH=$PATH:$GRADLE_HOME/bin

# sudo source /etc/profile.d/gradle-env.sh