【问题标题】:Android Emulator v/s PhoneAndroid 模拟器与手机
【发布时间】:2012-09-23 04:12:17
【问题描述】:

我正在运行我创建的使用 Google Maps API 的应用程序。

它在我正在使用的模拟器上按预期工作,但是,图形似乎在我的手机上以不同的方式呈现。

请参考以下图片

这是我的 activity.xml 文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:padding="@dimen/padding_medium"
    android:text="@string/hello_world"
    tools:context=".MainActivity" />



  <TextView
     android:id="@+id/textView1"
     android:layout_width="fill_parent"
     android:layout_height="30dp"
     android:background="@drawable/repeat"
     android:layout_marginTop="0dp"
     android:text=""
     android:textAppearance="?android:attr/textAppearanceLarge" /> 


   <com.google.android.maps.MapView
       android:id="@+id/mapView"
       android:layout_marginTop="30dp"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:enabled="true"
       android:clickable="true"
       android:apiKey="--private--" />

</RelativeLayout>

为什么同一张图片的观察结果不同——一张在设备上,一张在模拟器上?

【问题讨论】:

    标签: java android adb


    【解决方案1】:

    要在真实硬件上进行测试,您需要使用与调试密钥不同的密钥。我认为您正在使用调试密钥库。

    访问:https://developers.google.com/maps/documentation/android-api/v1/?csw=1#getfingerprint

    在谷歌上阅读该段落。

    应用程序导出为具有与 google api 相同的密钥(而不是调试密钥)的签名应用程序很重要。

    对于创建一个有效的阅读该段落:

    访问:http://developer.android.com/guide/publishing/app-signing.html#releasemode

    然后使用同一个key获取google maps api key。

    获得应用程序的密钥后,您可以通过在项目上单击鼠标右键选择 Android 工具,然后导出为已签名的应用程序包并按照向导来导出已签名的应用程序(可能您可以创建一个新的键使用该向导)。

    希望有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-15
      • 2020-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-07
      • 2010-12-26
      相关资源
      最近更新 更多