我在谷歌地图上工作很累,但找不到错误, 这里的错误是“”不幸bhk已停止工作“” 我在这里发布我的代码 请帮助我 这是我的显示文件
*
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bhk"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="19" />
<permission android:name="com.example.bhk.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<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_LOCAT"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAVqGlNT-a7_8IpOHFfE5GlBzL9pfmHCHM" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:allowBackup="true">
<activity android:name=".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>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>*
这是我的主要活动文件
*
package com.example.bhk;
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);
}
}
*
这是我的活动主体文件
*
<?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"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
*
康斯特尔的错误先生
[2014-03-05 03:16:54 - Android SDK]加载SDK时出现警告:
Warning: Missing file 'C:\Users\hp\.android\avd\bkj.avd\config.ini'.
[2014-03-05 03:20:31 - bhk] Dx
trouble writing output: already prepared
[2014-03-05 03:20:35 - bhk] ------------------------------
[2014-03-05 03:20:35 - bhk] Android Launch!
[2014-03-05 03:20:35 - bhk] adb is running normally.
[2014-03-05 03:20:35 - bhk] Performing com.example.bhk.MainActivity activity launch
[2014-03-05 03:20:36 - bhk] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'google-API'
[2014-03-05 03:20:36 - bhk] Uploading bhk.apk onto device 'emulator-5554'
[2014-03-05 03:20:41 - bhk] Failed to install bhk.apk on device 'emulator-5554': timeout
[2014-03-05 03:20:41 - bhk] Launch canceled!
在LOGCAT显示的时候
03-04 16:57:28.424: E/NetdConnector(383): NDC Command {81 bandwidth gettetherstats} took too long (786ms)
但是在Android设备上运行apk会显示错误 不幸的是abhk.apk已经停止了
更新MANIFEST FILE后的logcat。 @Emil
03-06 14:08:37.657:E / AndroidRuntime(1152):致命异常:主要 03-06 14:08:37.657:E / AndroidRuntime(1152):进程:com.example.bhk,PID:1152 03-06 14:08:37.657:E / AndroidRuntime(1152):android.content.ActivityNotFoundException:No Activity
发现处理Intent {act = android.intent.action.VIEW dat = market:// details?
id = com.google.android.gms flg = 0x80000 pkg = com.android.vending}
03-06 14:08:37.657:E / AndroidRuntime(1152):at
android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
03-06 14:08:37.657:E / AndroidRuntime(1152):at
android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
03-06 14:08:37.657:E / AndroidRuntime(1152):at
android.app.Activity.startActivityForResult(Activity.java:3424) 03-06 14:08:37.657:E / AndroidRuntime(1152):at
android.app.Activity.startActivityForResult(Activity.java:3385)
03-06 14:08:37.657:E / AndroidRuntime(1152):at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
答案 0 :(得分:0)
清单文件中存在一些问题:
那些部分:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAVqGlNT-a7_8IpOHFfE5GlBzL9pfmHCHM" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
应位于application
配置单元下,此部分应删除:
<uses-library android:name="com.google.android.maps" />
因为它是Google Maps API V1
的一部分,所以:
<activity android:name=".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="AIzaSyAVqGlNT-a7_8IpOHFfE5GlBzL9pfmHCHM" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
</application>
另一件事是你错过了这个权限:
<uses-permission android:name="com.example.bhk.permission.MAPS_RECEIVE"/>
此外,我建议你回顾一下我在这个主题上写的指南: