sor*_*ist 100 android google-maps android-mapview google-maps-android-api-2
我正在测试适用于Android的新Google Maps API V2,并在应用启动时收到此消息:
这是在4.1模拟器上运行.
这是我的AndroidManifest.xml
档案:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<permission
android:name="com.example.maptest.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Require OpenGL ES version 2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<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="##myapikey##"/>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
文件MainActivity.java:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
文件activity_main.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" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
单击"更新"会使用以下堆栈跟踪崩溃应用程序:
E/Trace(1034): error opening trace file: No such file or directory (2)
W/GooglePlayServicesUtil(1034): Google Play services out of date. Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date. Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date. Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date. Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date. Requires 2010100 but found 1
W/GooglePlayServicesUtil(1034): Google Play services out of date. Requires 2010100 but found 1
D/gralloc_goldfish(1034): Emulator without GPU emulation detected.
D/AndroidRuntime(1034): Shutting down VM
W/dalvikvm(1034): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
E/AndroidRuntime(1034): FATAL EXCEPTION: main
E/AndroidRuntime(1034): android.content.ActivityNotFoundException: No Activity found to handle Intent
{ act=android.intent.action.VIEW dat=http://play.google.com/store/apps/details? \
id=com.google.android.apps.bazaar flg=0x80000 pkg=com.android.vending }
E/AndroidRuntime(1034): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
E/AndroidRuntime(1034): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
E/AndroidRuntime(1034): at android.app.Activity.startActivityForResult(Activity.java:3351)
E/AndroidRuntime(1034): at android.app.Activity.startActivityForResult(Activity.java:3312)
E/AndroidRuntime(1034): at android.app.Activity.startActivity(Activity.java:3522)
E/AndroidRuntime(1034): at android.app.Activity.startActivity(Activity.java:3490)
E/AndroidRuntime(1034): at com.google.android.gms.internal.c$2.onClick(Unknown Source)
E/AndroidRuntime(1034): at android.view.View.performClick(View.java:4084)
E/AndroidRuntime(1034): at android.view.View$PerformClick.run(View.java:16966)
E/AndroidRuntime(1034): at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime(1034): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(1034): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(1034): at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime(1034): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(1034): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime(1034): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime(1034): at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
我还引用了Google Play服务项目.我在这做错了什么?
UPDATE
Google问题跟踪器(https://issuetracker.google.com/issues/35822258)中的相应错误已于前一段时间解决.
现在,您可以在模拟器中使用Google Maps Android API,并使用Play服务创建虚拟设备,如以下答案中所述:
Dan*_*ugh 56
UPDATE
Google maps API v2现已安装在最新的Google系统映像上(api:19 ARM或x86).
因此,您的应用程序应该只使用新图像.无需安装这些文件.
我一直在尝试在模拟器下运行Android Google Maps V2应用程序,一旦我最终运行Google Play服务,我将我的SDK更新为Google Play Services版本4,我的模拟器将不再运行我的应用程序.
我现在已经研究了如何从我的变压器平板电脑更新我的模拟器.(您不需要平板电脑,因为您可以下载以下文件.)
我使用Titanium Backup备份我的Asus Eee Pad Transformer(TF101),然后从备份中获取com.android.vending和com.google.android.gms APK文件.
我在配置了平台的仿真器上安装了这些:4.1.2,API级别:16,CPU Intel/Atom x86),我的Google Maps V2应用程序再次运行.
这就是全部..没有关于/ system/app的其他步骤是必需的.
我的应用程序仅使用Google Maps API,毫无疑问,如果您使用其他Google Play服务,则需要执行更多步骤.
最新Google Play服务的新文件:
与以前相同的说明:创建一个新的模拟器,包含任何CPU/ABI,非Google API目标(版本10-19工作)和GPU模拟开启或关闭,然后安装文件:
adb install com.android.vending-20140218.apk
adb install com.google.android.gms-20140218.apk
Run Code Online (Sandbox Code Playgroud)
如果要升级现有的模拟器,则可能需要通过以下方式卸载以前的版本:
adb uninstall com.android.vending
adb uninstall com.google.android.gms
Run Code Online (Sandbox Code Playgroud)
就这样.
nic*_*ico 42
根据Google+上与Android开发者的讨论,目前无法在模拟器上运行新的Map API.
(评论来自Zhelyazko Atanasov昨天23:18,我不知道如何直接链接到它)
此外,从实际设备运行时,您看不到" (通过Bazaar) "部分,更新按钮打开Play商店.我假设Bazaar是为了在Android模拟器上提供Google Play服务,但还没准备好......
Pah*_*aha 39
我花了大约一天的时间在Android模拟器上配置新的gmaps API(Google Maps Android API v2).我在互联网上找到的那些方法都没有对我有效.但我仍然这样做了.方法如下:
在我安装必要的应用程序时,由于各种错误,我无法配置其他版本.
2)启动模拟器并安装以下应用程序:
您可以使用以下命令执行此操作:
2.1)adb shell mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system
2.2)adb shell chmod 777 /system/app
2.3-2.5)adb push Each_of_the_3_apk_files.apk /system/app/
链接下载APK文件.我已经从我的root设备中复制了它们.
3)在模拟器上安装Google Play服务和Google地图.我有一个错误491,如果我从Google Play商店安装它们.我将应用程序上传到模拟器并在本地运行安装.(你可以adb
用来安装它).应用程序的链接:
4)在这些步骤之后,我在模拟器上成功运行了一个演示样本.这是一个截图:
Nem*_*vic 29
我第二次回答这个问题,因为我尝试过的解决方案一开始没有用,现在可以工作了,我可以重新创建让它工作的步骤:)
我也觉得缺少Google Play商店是罪魁祸首,因此我尝试通过此链接上的建议将Google Play商店安装到模拟器中并将此链接组合在一起.我遇到了一些困难,但最后我成功安装了Google Play商店并通过下载一些随机应用进行了测试.但是地图活动仍然使用"更新"按钮显示消息.那个按钮会把我带到商店,但在那里我会收到一条关于"找不到商品"的消息,地图仍然没有用.那时我放弃了.
昨天,我偶然启动了相同的测试应用程序,它工作正常!我很困惑,但很快我就从模拟器中做了一个差异,它正在工作,新的干净,我在/ data/app /目录中确定了两个应用程序:com.android.vending-1. apk和com.google.android.gms-1.apk.这很奇怪,因为当我按照这些网站的说明安装Google Play商店时,我正在推送Phonesky.apk,GoogleServicesFramework.apk和GoogleLoginService.apk以及其他文件夹/系统/应用.
无论如何,现在Android Google Maps API v2正在我的模拟器上工作.这些是执行此操作的步骤:
创建一个新的模拟器
这些是适合我的设置.我不知道不同的.
启动模拟器
通过ADB install命令安装com.android.vending-1.apk和com.google.android.gms-1.apk
Google地图现在可以在您的模拟器中使用.
归档时间: |
|
查看次数: |
211595 次 |
最近记录: |