除非您更新 Google Play 服务(通过 Bazaar),否则此应用程序不会运行

2024-01-15

我正在测试适用于 Android 的新 Google Maps API V2,当应用程序启动时我收到此消息:

这是在 4.1 模拟器上运行的。

这是我的AndroidManifest.xml file:

<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>

文件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;
    }
}

文件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>

单击“更新”会使应用程序崩溃,并显示以下堆栈跟踪:

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)

我还参考了 Google Play 服务项目。我在这里做错了什么?

UPDATE

Google问题跟踪器中的相应错误(https://issuetracker.google.com/issues/35822258 https://issuetracker.google.com/issues/35822258)前段时间已经解决了。

现在,您可以在模拟器中使用 Google Maps Android API 并使用 Play 服务创建虚拟设备,如本答案所述:

https://stackoverflow.com/a/46246782/5140781 https://stackoverflow.com/a/46246782/5140781


UPDATE

Google 地图 API v2 现已安装在最新的 Google 系统映像(api:19 ARM 或 x86)上。
因此您的应用程序应该只使用新图像。无需安装这些文件。

我一直在尝试在模拟器下运行 Android Google Maps V2 应用程序,当我最终运行 Google Play 服务后,我将 SDK 更新为 Google Play 服务修订版 4,但我的模拟器将不再运行我的应用程序。

我现在已经弄清楚如何从我的变压器平板电脑更新我的模拟器。 (您不需要平板电脑,因为您可以下载下面的文件。)

我使用 Titanium Backup 来备份我的华硕 Eee Pad 变压器 https://en.wikipedia.org/wiki/Asus_Eee_Pad_Transformer(TF101)然后抓住 com.android.vending 和 com.google.android.gmsAPK http://en.wikipedia.org/wiki/APK_%28file_format%29备份中的文件。

我将它们安装在配置平台:4.1.2、API 级别:16、CPU Intel/Atom x86)的模拟器上,并且我的 Google Maps V2 应用程序再次运行。

这就是全部......不需要有关 /system/app 的其他步骤。

我的应用程序仅使用Google Maps API,毫无疑问,如果您使用其他Google Play服务,则需要更多步骤。

最新 Google Play 服务的新文件:

  • com.google.android.gms-20140218.apk https://mega.co.nz/#!OR82UKbT!ualgRzV92D1-6SBD6wUqBKUgBpFoeYBKvotQUB2NWY4

  • com.android.vending-20140218.apk https://mega.co.nz/#!GQFDETTb!uWPygDxdTr81cd6QRQx-Iqn-9H6u3MKfMijS10ubkMI

与之前相同的说明:使用任何命令创建一个新的模拟器CPU http://en.wikipedia.org/wiki/Central_processing_unit/ABI https://en.wikipedia.org/wiki/Application_binary_interface,非 Google API 目标(版本 10-19 有效)以及GPU https://en.wikipedia.org/wiki/Graphics_processing_unit打开或关闭仿真,然后安装文件:

adb install com.android.vending-20140218.apk
adb install com.google.android.gms-20140218.apk

如果您要升级现有模拟器,则可能需要通过以下方式卸载以前的版本:

adb uninstall com.android.vending
adb uninstall com.google.android.gms

就这样。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

除非您更新 Google Play 服务(通过 Bazaar),否则此应用程序不会运行 的相关文章

随机推荐