首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当应用程序在手机上运行时(从bin文件夹的.apk文件安装),会显示灰色平铺屏幕

当应用程序在手机上运行时(从bin文件夹的.apk文件安装),会显示灰色平铺屏幕
EN

Stack Overflow用户
提问于 2013-07-02 00:52:36
回答 2查看 338关注 0票数 0

我在我的android手机上安装了apk,使用的是bin文件夹中的apk,当我在eclipse(手机已连接)上运行这个应用程序时,它会在手机上运行,但只显示灰色的磁贴。该怎么办呢?

MainActivity.java

代码语言:javascript
复制
   package com.example.lbs;

      import android.os.Bundle;
       import android.app.Activity;
      import android.view.Menu;
      import com.google.android.maps.MapActivity;

      public class MainActivity extends MapActivity {

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

 }

LBS清单文件

代码语言:javascript
复制
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.example.lbs"
 android:versionCode="1"
 android:versionName="1.0" >

 <uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

  <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <uses-library android:name="com.google.android.maps"    />    
    <activity
        android:name="com.example.lbs.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>

    <meta-data
         android:name="com.google.android.maps.v2.API_KEY"
         android:value="AIzaSyCROYDMk81v3LCsQShUnMjnezyshJAvJdY"/>

  </application>

  <permission
    android:name="com.example.lbs.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>

 <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE"/>
  <uses-permission  android:name="android.permission.INTERNET"></uses-permission>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 <uses-permission          android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
 <!-- The following two permissions are not required to use
 Google Maps Android API v2, but are recommended. -->
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>"
 </manifest>

activity_main.xml

代码语言:javascript
复制
  <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"
  android:paddingBottom="@dimen/activity_vertical_margin"
   android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context=".MainActivity" >

  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

  <com.google.android.maps.MapView 
    android:id="@+id/mapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:enabled="true"
    android:clickable="true"
    android:apiKey="AIzaSyCROYDMk81v3LCsQShUnMjnezyshJAvJdY"  /> 


    </RelativeLayout>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-03-03 18:00:05

Ok...so我犯了以下错误:

1)我使用了Mapview,然后我将其更改为片段视图。感谢@Gabe Sechan告知我们

Simple android program using GOOGLE MAP API就是一个例子

2)当我导入google play服务时,我没有导入到我的工作空间中,这导致了错误

修复此类错误:- Google Maps Can't add reference to Play Services

使用谷歌地图应用程序接口v2的新手最佳链接:http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/

票数 1
EN

Stack Overflow用户

发布于 2013-07-02 00:58:03

使用什么证书对APK进行签名?确保在生成API密钥时添加了调试证书和版本证书的指纹。请参阅此处的更多说明:

https://developers.google.com/maps/documentation/android/start

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17409699

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档