使谷歌播放服务4.0.30工作与Android工作室0.4.2和放大器;摇篮0.7 [英] Making Google Play Services 4.0.30 work with Android Studio 0.4.2 & Gradle 0.7

查看:265
本文介绍了使谷歌播放服务4.0.30工作与Android工作室0.4.2和放大器;摇篮0.7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎没有可用获取谷歌播放服务使用的是Android工作室的工作解决方案的不足。我尝试了一大半。经过反复试验后很多错误,我来,为了让许多这些解决方案的工作,你必须拥有的版本,因为这些解决方案的作者的确切组合的结论。这个神奇的组合似乎有多么成功,你将与任何特定的解决方案,一个非常现实的作用。我相信,我还没有发现的软件,我现在用的版本的解决方案,但不排除我已经错过了一些简单的机会/愚蠢所以请温柔。

因此​​,这里是我的设置,希望有人能够看到的问题: 我总是从头开始。这样,我知道我没有从旧版本会惹我任何挥之不去的污泥。我使用的是Android工作室(preVIEW)0.4.2,摇篮0.7(每build.gradle文件),并正尝试使用谷歌播放服务4.0.30,这样我可以使用谷歌地图V2。

我已经打开了SDK管理器和下载每个更新,并确认我所有的SDK工具加载,所有的API 19的加载(以及许多较低版本的加载,包括14,和所有的额外的装载,包括支持资源库,支持库,和谷歌播放服务。基本上,我错在过度下载的一面。

在这种配置,我可以:

 进口com.google.android.gms。*
 

但没有.maps或其他任何所以没有GoogleMap的等。

我将展示一些关键文件的内容。很抱歉的长度,但也有可能是一些隐藏在我不希望一个地方,我不会想不显示的问题。所以,请大家多多包涵。 ......如果有人需要看到更多,请让我知道了。 THX

我的build.gradle:

  buildscript {
    库{
        mavenCentral()
    }
    依赖{
        类路径com.android.tools.build:gradle:0.7.+
    }
}
应用插件:'机器人'

库{
    mavenCentral()
}

安卓{
    compileSdkVersion 19
    buildToolsVersion19.0.0

    defaultConfig {
        的minSdkVersion 14
        targetSdkVersion 19
    }
    buildTypes {
        推出 {
            runProguard真
            proguardFile getDefaultProguardFile('ProGuard的-的Andr​​oid optimize.txt)
        }
    }
    productFlavors {
        defaultFlavor {
            proguardFileProGuard的,rules.txt
        }
    }
}
依赖{
    //谷歌播放服务
    编译com.google.android.gms:播放服务:4.0.30
    //支持库
    编译com.android.support:support-v4:19.0.0
    编译com.android.support:appcompat-v7:19.0.0
    编译com.android.support:gridlayout-v7:19.0.0
    编译com.android.support:support-v13:19.0.0
}
 

我的ProGuard-rules.txt:

  -keep类*扩展java.util.ListResourceBundle {
    保护的对象[] [] getContents();
}

#保持SafeParcelable价值,需要进行反思。这是REQD向后支持
#兼容一些类。
-keep公共类com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    公共静态最终*** NULL;
}

#保持我们需要的客户端功能的类/成员的名字。
-keepnames @ com.google.android.gms.common.annotation.KeepName类*
-keepclassmembernames类* {
    @ com.google.android.gms.common.annotation.KeepName *;
}

#所需的Parcelable / SafeParcelable创作者没有得到剥离
-keepnames类*实现android.os.Parcelable {
    公共静态最后的** CREATOR;
}
 

我的Andr​​oidManifest.xml:

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.klhsoftware.k4wmapp>
    <许可
        机器人:名称=com.klhsoftware.k4wmapp.permission.MAPS_RECEIVE
        安卓的ProtectionLevel =签名/>
    <使用-权限的Andr​​oid:名称=com.klhsoftware.k4wmapp.permission.MAPS_RECEIVE/>
    <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用-权限的Andr​​oid:名称=com.google.android.providers.gsf.permission.READ_GSERVICES/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_COARSE_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION/>
    <用途特征
        机器人:glEsVersion =0x00020000
        机器人:要求=真/>
    <应用
        机器人:allowBackup =真
        机器人:图标=@可绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ AppTheme
        机器人:hardwareAccelerated =真正的>
        <活动
            机器人:名称=com.klhsoftware.k4wmapp.MapScreen
            机器人:标签=@字符串/ APP_NAME>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>
                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
        <供应商
            机器人:名称=LocationsContentProvider
            机器人:当局=in.wptrafficanalyzer.locationmarkersqlite.locations
            机器人:出口=FALSE/>
        &所述;元数据
            机器人:名称=com.google.android.maps.v2.API_KEY
            机器人:值=AIza< myvalue的> -tsldkfjdOM/>
    < /用途>
< /舱单>
 

解决方案

我们已经看到的问题没有得到妥善拿起新增库;我认为这是错误的 https://开头code。 google.com/p/android/issues/detail?id=64508 将其固定在0.4.3。在此期间,

  • 退出Android的工作室
  • 备份你的项目
  • 删除所有.iml文件和文件夹.idea
  • 在重新启动的Andr​​oid Studio和重新导入你的项目

这是相同的答案为<一个href="http://stackoverflow.com/questions/21100688/android-studio-0-4-2-suddenly-cannot-resolve-symbols">Android工作室0.4.2突然不能解析符号

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.

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.

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.*

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

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

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

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>

解决方案

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,

  • Exit Android Studio
  • Back up your project
  • Delete all the .iml files and the .idea folder
  • Relaunch Android Studio and reimport your project

This is the same answer as Android Studio 0.4.2 suddenly cannot resolve symbols

这篇关于使谷歌播放服务4.0.30工作与Android工作室0.4.2和放大器;摇篮0.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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