gpt4 book ai didi

android - 使 Google Play 服务 4.0.30 与 Android Studio 0.4.2 和 Gradle 0.7 一起工作

转载 作者:搜寻专家 更新时间:2023-11-01 08:53:20 25 4
gpt4 key购买 nike

使用 Android Studio 让 Google Play Services 工作的解决方案似乎并不缺乏。我已经尝试了其中的大部分。经过多次试验和多次错误后,我得出结论,为了使这些解决方案中的许多解决方案起作用,您必须拥有与这些解决方案的作者相同的版本组合。这种神奇的组合似乎对您使用任何给定解决方案的成功程度有着非常真实的影响。我相信我还没有找到适合我正在使用的软件版本的解决方案,但不排除我错过了一些简单/愚蠢的事情的可能性,所以请保持温和。

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

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

通过这个配置我可以:

import  com.google.android.gms.*

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

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

我的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:

-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:

<?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 中修复。与此同时,

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

这与 Android Studio suddenly cannot resolve symbols 的答案相同

关于android - 使 Google Play 服务 4.0.30 与 Android Studio 0.4.2 和 Gradle 0.7 一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21103163/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com