【问题标题】:Google Map V2 Not Working - On my Android Device - Nexus 4Google Map V2 不工作 - 在我的 Android 设备上 - Nexus 4
【发布时间】:2014-01-06 14:20:02
【问题描述】:

在这方面需要您的帮助。我在解决以下错误时陷入双重绑定。

当我从 Java 构建路径/顺序和导出中检查“Android 依赖项”和“私有库”时。 我收到错误 - “Java dex 堆空间错误” - 我尝试在 eclipse.ini 文件中将 XMAX 大小增加到 8536m - 但仍然存在 Java dex 堆空间错误。

当我从 Java 构建路径中取消选中“Android 依赖项”和“私有库”时。 我得到“Java.lang.Class Not Found Exception - of com.example.googlemaps.MainActivity

我使用的是 JDK 1.7

在这里附上所有东西:

项目结构

Android 清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemaps"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission android:name="com.example.googlemaps.permission.MAPS_RECEIVE"           android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Required OpenGL ES 2.0. for Maps V2 -->
<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" >
<activity
    android:name="com.example.googlemaps.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
</application> 

<!-- Goolge API Key -->
 <meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="AIzaSyCOhACbfq4DORsY56MQF38FiKqXC0-A1wc" />

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</manifest>

MainActivity.Java

package com.example.googlemaps;

import com.google.android.gms.maps.GoogleMap;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class MainActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
 }
}

Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

 <fragment
    android:name="com.google.android.gms.maps.SupportMapFragment"

    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</LinearLayout>

Eclipse.ini

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120913-144807
-product
com.android.ide.eclipse.adt.package.product
--launcher.XXMaxPermSize
8512M
-showsplash
com.android.ide.eclipse.adt.package.product
--launcher.XXMaxPermSize
8512m
--launcher.defaultAction
openFile
-vm
C:/Program Files (x86)/Java/jdk1.7.0_25/bin/javaw.exe
-Dosgi.requiredJavaVersion=1.6
-Xms8536m
-Xmx8536m
-Declipse.buildId=v22.0.5-757759

dx.bat 中的位置:C:\Users\nikshrivastava\Downloads\adt-bundle-windows-x86-20130729\sdk\build-tools\android-4.3

:JarFileOk

set jarpath=%frameworkdir%%jarfile%

set javaOpts=
set args=

REM By default, give dx a max heap size of 1 gig and a stack size of 1meg.
rem This can be overridden by using "-JXmx..." and "-JXss..." options below.
set defaultXmx=-Xmx1624M
set defaultXss=-Xss1m

【问题讨论】:

    标签: android eclipse google-maps


    【解决方案1】:

    首先检查您的 Java 版本。如果不是 1.6 更新到 1.6 或 1.7 第二:这可以通过增加位于您的 Android SDK 中的 dx.jar 的堆内存大小来解决。

    这可以通过

    编辑 dx.bat 文件 adt-bundle-windows-x86_64-20130729\adt-bundle-windows-x86_64-20130729\sdk\build-tools\android-4.3\dex.bat 并更新其设置 defaultXmx=-Xmx1024M值设置 defaultXmx=-Xmx1624M

    如果这不起作用检查这个灵魂:

    Conversion to Dalvik format failed: Unable to execute dex: Java heap space

    【讨论】:

    • 感谢您的 i/p,但仍然无法正常工作。已更新您提出的更改。
    • 将您的 MinSdk 更改为 9
    • 什么都没有改变,我安装了Android Studio,会在那里试试我的谷歌地图!
    • 您找到解决方案了吗?我也被困在现场没有修复。其他人如何让它发挥作用?很遗憾我的下一步是放弃 eclipse 并尝试 android studio ......谁知道我会有多少问题!
    • 嘿,令人惊讶的是它有效,我尝试使用旧版本 - “google play Services lib” - 版本 8。它有效。 -- 所以不要使用最新版本的“google play services lib”。试试旧的,最新的可能有一些配置问题,我不确定。
    【解决方案2】:

    我尝试使用“Google Play Services lib”版本 8 的旧版本 - 并且成功运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-26
      • 1970-01-01
      • 2015-06-07
      • 2013-08-02
      相关资源
      最近更新 更多