似乎不乏解决方案可用于使用Android Studio来使Google Play服务正常工作。我已经尝试了大多数。经过大量的尝试和错误,我得出的结论是,要使这些解决方案中的许多起作用,您必须具有与这些解决方案的作者一样的确切版本组合。这种神奇的组合似乎对任何给定解决方案的成功程度都有非常实际的影响。我相信我尚未找到所用软件版本的解决方案,但还没有排除我错过简单/愚蠢的东西的可能性,请保持谦虚。
因此,这是我的设置,希望有人能够看到该问题:我总是从头开始。这样,我知道我不会从旧版本中留下任何挥之不去的污泥。我正在使用Android Studio(预览版)0.4.2,gradle 0.7(每个build.gradle文件),并且正在尝试使用Google Play服务4.0.30,以便可以使用Google Maps V2。
我已打开SDK管理器并下载了所有更新,并验证是否已加载所有SDK工具,所有API 19(以及许多较低版本,包括14,以及所有Extras,包括支持存储库,支持)。图书馆和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突然无法解析符号的答案相同
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句