Retrofit: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Line 57: Line 57:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
</syntaxhighlight>
</syntaxhighlight>
I also need to change the SDK build toools in the app to be
I also need to change the SDK build toools in the app to be 26
<syntaxhighlight lang="groovy">
<syntaxhighlight lang="groovy">
:q
android {
android {
     compileSdkVersion 26
     compileSdkVersion 26
Line 66: Line 65:
         applicationId "com.example.alexr.ideamanager"
         applicationId "com.example.alexr.ideamanager"
         minSdkVersion 21
         minSdkVersion 21
         targetSdkVersion 25
         targetSdkVersion 26
         versionCode 1
         versionCode 1
         versionName "1.0"
         versionName "1.0"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
     }
</syntaxhighlight>
</syntaxhighlight>

Revision as of 03:32, 24 January 2021

Resource

During the course there were demo server APIs
https://github.com/alex-wolf-ps/RetrofitAPINode
https://github.com/alex-wolf-ps/RetrofitAPIDotnet
https://github.com/alex-wolf-ps/AndroidGlobomanticsApp

Old Projects

Use Java 8

Sometimes when using older projects with gradle you might see

Couldn't determine java version from '11.0.1'

This is because of an old version of gradle. The easiest way to solve it is to go to the command line and change your JAVA_HOME is 8 e.g.

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Gradle 3.3 to 4.10

To achieve this I change the build.gradle to update the plugin and specify the maven and google repositories.

buildscript {
    repositories {
        google()
        jcenter()
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

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

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

And ran gradlew not gradle and also updated the gradle.warapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

From there I could use the standard update to 4.10

./gradlew wrapper --gradle-version 4.10

Gradle 4.10 to 5.4.1

For this I needed to change the plugin in build.gradle to be

   classpath 'com.android.tools.build:gradle:3.5.1'

And of course the gradle.warapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

I also need to change the SDK build toools in the app to be 26

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.example.alexr.ideamanager"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }