GoogleMap Android API 示例不起作用
GoogleMap Android API sample doesn't work
我尝试从本教程(https://github.com/googlemaps/android-samples) 学习Google 地图API。
但是,当我 运行 应用程序时,我收到了错误消息。
这个问题很简单,但我是使用 android studio 和 Google Map API 的初学者。所以我想解决这个问题....
请多多指教
错误信息
'Execution failed for task':app:transformClassesWithDexForDebug'
com.android.build.api.transform.TransformException:
java.util.concurrent.ExecutionException:com.android.dex.DeIndexOverFlowException:
method ID not in [0,0xffff]:65536
这就是我做的。
1) 下载 zip 文件。 (https://github.com/googlemaps/android-samples)
2)打开AndroidStudio并导入项目
来自使用 'Import project(Eclipse ADT,Gradle,etc...)'
3)在'gradle.properties'文件中输入Google MAP API键。
4)运行
你的方法太多了。 dex只能有65536个方法
您需要包含 multi-dex
在构建中添加这些行 gradle
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
同样在您的清单中将 MultiDexApplication class 从 multidex 支持库添加到应用程序元素
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
我假设您指的是 googlemaps/android-samples
下的 ApiDemos 和教程
- ApiDemos 使用
compile 'com.google.android.gms:play-services-maps'
- 教程使用
compile 'com.google.android.gms:play-services'
第二个将处理所有播放服务 api 而不是特定的服务。所以你面临65K的限制问题。
尝试对 googlemaps/android-samples
下的所有样本使用单独的 api(如 com.google.android.gms:play-services-maps
)
我尝试从本教程(https://github.com/googlemaps/android-samples) 学习Google 地图API。 但是,当我 运行 应用程序时,我收到了错误消息。 这个问题很简单,但我是使用 android studio 和 Google Map API 的初学者。所以我想解决这个问题....
请多多指教
错误信息
'Execution failed for task':app:transformClassesWithDexForDebug' com.android.build.api.transform.TransformException: java.util.concurrent.ExecutionException:com.android.dex.DeIndexOverFlowException: method ID not in [0,0xffff]:65536
这就是我做的。
1) 下载 zip 文件。 (https://github.com/googlemaps/android-samples)
2)打开AndroidStudio并导入项目 来自使用 'Import project(Eclipse ADT,Gradle,etc...)'
3)在'gradle.properties'文件中输入Google MAP API键。
4)运行
你的方法太多了。 dex只能有65536个方法
您需要包含 multi-dex
在构建中添加这些行 gradle
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
同样在您的清单中将 MultiDexApplication class 从 multidex 支持库添加到应用程序元素
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
我假设您指的是 googlemaps/android-samples
下的 ApiDemos 和教程- ApiDemos 使用
compile 'com.google.android.gms:play-services-maps'
- 教程使用
compile 'com.google.android.gms:play-services'
第二个将处理所有播放服务 api 而不是特定的服务。所以你面临65K的限制问题。
尝试对 googlemaps/android-samples
下的所有样本使用单独的 api(如com.google.android.gms:play-services-maps
)