Skip to content
Advertisement

Android Studio – Error Module not specified

i’m a newbie to Android/Java development and purchased a book Java Programming for Android Developers For Dummies, 2nd Edition.

This comes with a code samples section http://users.drew.edu/bburd/Java4Android/ (chapter 02_01) I understand the book is a few years old hence so the code samples will be. However, i’m having massive problems getting the code samples to run on Android Studio 4.1.2.

I can import the project and sync the Gradle files. When I do it appears with a green tick at the bottom. Oddly it says failed next to that with the following message.

Gradle sync failed: Unsupported method: SyncIssue.getMultiLineMessage().
            The version of Gradle you connect to does not support that method.
            To resolve the problem you can change/upgrade the target version of Gradle you connect to.
            Alternatively, you can ignore this exception and read other information from the model.
            Consult IDE log for more details (Help | Show Log) (1 s 443 ms)

My build.gradle file is as follows

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

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

allprojects {
    repositories {
        jcenter()
    }
}

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

Also if I try and run the project I see this screen Error message

main screen

I’ve read many posts with similar issues and worked through various fixes. None seemed to work so can anyone shed any light on what’s happening please? I’ve also downloaded android studio on 3 different PC’s incase its a bug of some sort.

Thank you

Advertisement

Answer

I should say the files in there are very outdated, and you will have very hard time, with every project. But if you still want to build the project here are a few things you can do.

look for the file gradle-wrapper.properties and update it with this

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip

Then move to project level build.gradle file (there are two one inside app directory and one on the root directory, use the root directory)

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

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

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

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

Then move to app level build.gradle and update it with this

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.allyourcode.a02_01"
        minSdkVersion 15
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:2.0.4'
    testImplementation 'junit:junit:4.13.1'
}

And then sync the project and let Android studio do its magic.

Advertisement