无法打开地图片段

时间:2015-12-24 23:15:45

标签: android google-maps

我正在尝试将地图片段添加到活动中。对于我的例子,我使用这篇官方文章:https://developers.google.com/maps/documentation/android-api/ 但在使用地图片段打开活动后,我的应用程序立即关闭。在日志中我有这样的错误: “E / dalvikvm:找不到类'android.app.AppOpsManager',从com.google.android.gms.common.mw.a方法引用”

我的傻瓜:

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'
}

之后,根据我添加multidex的可能性 Getting error: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza,但它无法解决问题。 可能有什么问题?

1 个答案:

答案 0 :(得分:0)

您的targetSdkVersion为23,AppsOpsManager在API 19及更高版本中可用。您缺少的是在compile 'com.android.support:multidex:1.0.0'文件中添加multiDexEnabled truebuild.gradle以启用multidex功能。