unable to identify statement 'import com.google.android.maps.MapActivity; '

Viewed 134

I have recently cloned an already running code in android studio. I am stuck in this error for couple of days now, I am using a class AbstractMapAcivity which extends MapActivity class from "com.google.android.maps". Android studio gives the below error:

error: package com.google.android.maps does not exist

please help android/android studio experts, I am new to android development. Have a look at the supporting classes and project settings

build. gradle : app

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion "Google Inc.:Google APIs:23"
    buildToolsVersion '23.0.3'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.nccatalog"
        minSdkVersion 14
        targetSdkVersion 23
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/DEPENDENCIES'
    }

}

dependencies {
    compile "com.android.support:support-v4:${supportLibVersion}"
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:mediarouter-v7:${supportLibVersion}"
    compile "com.google.android.gms:play-services-gcm:${gcmLibVersion}"
    compile "com.google.code.gson:gson:${gsonLibVersion}"
    compile files('libs/FlurryAnalytics-4.2.0.jar')
    compile files('libs/gcm.jar')
    compile files('libs/com.radaee.view.jar')
    compile files('libs/httpcore-4.3.jar')
    compile files('libs/org.apache.commons.io.jar')
    compile files('libs/universal-image-loader-1.9.3-SNAPSHOT.jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
}

build.gradle : project

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'io.fabric.tools:gradle:1.30.0'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

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

ext {
    supportLibVersion = '23.4.0'
    gcmLibVersion = '8.3.0'
    gsonLibVersion = '2.7'
}

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

AbstractMapActivity.java

package com.utils.ui;

import android.app.Activity;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;

import com.google.android.maps.MapActivity;
import com.utils.application.ApplicationController;

public class AbstractMapAcivity extends MapActivity implements ActivityHelper {

    private ActivityHelper ah = new ActivityHelperImpl(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ApplicationController.activityStack.add(this);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        ApplicationController.activityStack.remove(this);
        super.onDestroy();
    }

    @Override
    public void hideKeyboard(View view) {

        ah.hideKeyboard(view);

    }

    @Override
    public Typeface createTypeFace(String fontName) {

        return ah.createTypeFace(fontName);

    }

    @Override
    public Drawable createRepeatableDrawable(int imageId) {
        return ah.createRepeatableDrawable(imageId);
    }

    @Override
    public boolean isNetworkAvailable(Activity activity) {
        return ah.isNetworkAvailable(activity);
    }

    @Override
    protected boolean isRouteDisplayed() {

        return false;
    }

    @Override
    public void switchToActivity(Activity current,
                                 Class<? extends Activity> otherActivityClass, Bundle extras) {

        ah.switchToActivity(current, otherActivityClass, extras);

    }

    @Override
    public void goToActivity(Activity current,
                             Class<? extends Activity> otherActivityClass, Bundle extras) {

        ah.goToActivity(current, otherActivityClass, extras);
    }

    @Override
    public void initUI() {

    }

}
2 Answers

In your build.gradle (app)

dependencies {
    //Your other compile dependencies (replace compile with implementation on them)

    implementation 'com.google.android.gms:play-services-maps:17.0.1' 
}

Seems like you are at least missing this line which should import maps, maybe other things are also missing that I can't see right now.

Take a look at this guide if you haven't already: https://developers.google.com/maps/documentation/android-sdk/start

There is also a guide for existing projects (I assume you need information from both of them)

https://developers.google.com/maps/documentation/android-sdk/config

Go inside the project build.gradle

Open the Gradle you see in the picture. Once it is open you will find the next image-like page, in dependencies add your dependency. And sync your file as well.

Make sure to update the version

Related