使 Google Play Services 4.0.30 与 Android Studio 0.4.2 & 一起工作0.7 级 [英] Making Google Play Services 4.0.30 work with Android Studio 0.4.2 & Gradle 0.7

查看:26
本文介绍了使 Google Play Services 4.0.30 与 Android Studio 0.4.2 & 一起工作0.7 级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎并不缺乏让 Google Play 服务使用 Android Studio 工作的解决方案.我已经尝试了其中的大部分.经过多次试验和多次错误,我得出的结论是,为了使这些解决方案中的许多解决方案起作用,您必须拥有作为这些解决方案作者的确切版本组合.这种神奇的组合似乎对您使用任何给定解决方案的成功程度产生了非常实际的影响.我相信我还没有找到我正在使用的软件版本的解决方案,但不排除我错过了一些简单/愚蠢的东西的机会,所以请温柔.

There doesn't seem to be a shortage of solutions available for getting Google Play Services to work using Android Studio. I’ve tried most of them. After much trial and much error I’ve come to the conclusion that in order for many of these solutions to work you must have the exact combinations of versions as the authors of these solutions. This magic combination seems to have a very real effect on how successful you will be with any given solution. I believe that I have not found the solution for the versions of software that I am using, but haven’t ruled out the chance I have missed something simple/stupid so please be gentle.

所以这是我的设置,希望有人能够看到问题:我总是从头开始.这样我就知道我没有任何旧版本中挥之不去的污泥,这会让我感到困惑.我正在使用 Android Studio(预览版)0.4.2、gradle 0.7(每个 build.gradle 文件),并且我正在尝试使用 Google Play Services 4.0.30,以便我可以使用 Google Maps V2.

So here is my setup and hopefully someone will be able to see the problem: I always start from scratch. That way I know I don’t have any lingering sludge from an older version that would mess with me. I am using Android Studio (Preview) 0.4.2, gradle 0.7 (per build.gradle file), and am trying to use Google Play Services 4.0.30 so that I can use Google Maps V2.

我打开了 SDK 管理器并下载了每个更新并验证我已加载所有 SDK 工具,加载了所有 API 19(以及加载了许多较低版本,包括 14,以及加载了所有附加功能,包括支持存储库、支持库和 Google Play 服务.基本上我在过度下载方面犯了错误.

I have opened the SDK Manager and have downloaded every update and verified that I have all the SDK tools loaded, all of API 19 loaded (and many of the lower versions loaded including 14, and all of the Extras loaded including the Support Repository, Support Library, and Google Play Services. Basically I’ve erred on the side of over-downloading.

通过这种配置,我可以:

With this configuration I can:

import  com.google.android.gms.*

但没有 .maps 或其他任何东西,所以没有 GoogleMap 等

but no .maps or anything else so no GoogleMap etc.

我将展示一些关键文件的内容.抱歉,篇幅过长,但可能有些东西隐藏在我意想不到的地方,我不想不显示"这个问题.所以请耐心等待....如果有人需要查看更多信息,也请告诉我.谢谢

I’ll show the contents of some key files. Sorry for the length but there may be something hiding in a place I wouldn’t expect and I wouldn’t want to ‘not show’ the problem. So please bear with me. ...And if someone needs to see more please let me know too. Thx

我的 build.gradle:

My build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }
    buildTypes {
        release {
            runProguard true
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
        }
    }
    productFlavors {
        defaultFlavor {
            proguardFile 'proguard-rules.txt'
        }
    }
}
dependencies {
    // Google Play Services
    compile 'com.google.android.gms:play-services:4.0.30'
    // Support Libraries
    compile 'com.android.support:support-v4:19.0.0'
    compile 'com.android.support:appcompat-v7:19.0.0'
    compile 'com.android.support:gridlayout-v7:19.0.0'
    compile 'com.android.support:support-v13:19.0.0'
}

我的 proguard-rules.txt:

My proguard-rules.txt:

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

# Keep SafeParcelable value, needed for reflection. This is reqd to support backwards
# compatibility of some classes.
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

# Keep the names of classes/members we need for client functionality.
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

# Needed for Parcelable/SafeParcelable Creators to not get stripped
-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

我的 AndroidManifest.xml:

My AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.klhsoftware.k4wmapp" >
    <permission
        android:name="com.klhsoftware.k4wmapp.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
    <uses-permission android:name="com.klhsoftware.k4wmapp.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:hardwareAccelerated="true">
        <activity
            android:name="com.klhsoftware.k4wmapp.MapScreen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <provider
            android:name="LocationsContentProvider"
            android:authorities="in.wptrafficanalyzer.locationmarkersqlite.locations"
            android:exported="false" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIza<myValue>-tsldkfjdOM" />
    </application>
</manifest>

推荐答案

我们一直看到新添加的库没有被正确使用的问题;我认为这是错误 https://code.google.com/p/android/issues/detail?id=64508 将在 0.4.3 中修复.与此同时,

We've been seeing problems with newly added libraries not getting properly picked up; I think this is bug https://code.google.com/p/android/issues/detail?id=64508 which will be fixed in 0.4.3. In the meantime,

  • 退出 Android Studio
  • 备份您的项目
  • 删除所有 .iml 文件和 .idea 文件夹
  • 重新启动 Android Studio 并重新导入您的项目

这与Android Studio 突然无法解析相同的答案符号

这篇关于使 Google Play Services 4.0.30 与 Android Studio 0.4.2 &amp; 一起工作0.7 级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆