0

I'm trying to add map fragment to activity. For my example I use this official article:https://developers.google.com/maps/documentation/android-api/ But after opening activity with map fragment, my app immediately closed. In logs I have errors like this: "E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.mw.a"

My gradle:

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    defaultConfig {
        applicationId "....."
        minSdkVersion 14
        targetSdkVersion 23
        versionCode VERSION_CODE
        versionName VERSION_NAME
    }

    signingConfigs {
        debug {
            storeFile file("keys/debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
        release {

        }
    }

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

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

    lintOptions {
        // If true, stop the gradle build if errors are found.
        abortOnError false
        htmlReport true
        disable "RtlHardcoded", "RtlSymmetry", "RtlEnabled", "RelativeOverlap"
        disable 'InvalidPackage'
    }

    def APK_NAME = PROJECT_NAME + "-" + VERSION_NAME + ".apk"
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            if (variant.buildType.name.equals("debug")) {
                output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace("app-debug.apk", APK_NAME))
            } else {
                output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace("app-release.apk", APK_NAME))
            }
        }
    }
}

File propFile = file('signing.properties');
if (propFile.exists()) {
    def Properties props = new Properties()
    props.load(new FileInputStream(propFile))

    if (props.containsKey('RELEASE_STORE_FILE') && props.containsKey('RELEASE_STORE_PASSWORD') &&
            props.containsKey('RELEASE_KEY_ALIAS') && props.containsKey('RELEASE_KEY_PASSWORD')) {
        android.signingConfigs.release.storeFile = file(props['RELEASE_STORE_FILE'])
        android.signingConfigs.release.storePassword = props['RELEASE_STORE_PASSWORD']
        android.signingConfigs.release.keyAlias = props['RELEASE_KEY_ALIAS']
        android.signingConfigs.release.keyPassword = props['RELEASE_KEY_PASSWORD']
    } else {
        android.buildTypes.release.signingConfig = null
    }
} else {
    android.buildTypes.release.signingConfig = null
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.squareup.okio:okio:1.6.0'
    compile 'com.google.code.gson:gson:2.3'
    compile 'org.parceler:parceler:0.2.15'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.pixplicity.easyprefs:library:1.7'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.borax12.materialdaterangepicker:library:1.2'
    compile 'io.realm:realm-android:0.84.1'
    compile 'com.cocosw:bottomsheet:1.1.1@aar'
    compile 'io.socket:socket.io-client:0.6.1'
}

After that, I add multidex possibility according to Getting error: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza, but it does not resolve the problem. What can be a problem?

Community
  • 1
  • 1
Alexander
  • 13
  • 4

1 Answers1

0

Your targetSdkVersion is 23 and the AppsOpsManager is available in API 19 and above. What you are missing is to add compile 'com.android.support:multidex:1.0.0' or multiDexEnabled true in the build.gradle file in order to enable the multidex function.

gerardnimo
  • 1,444
  • 8
  • 10