【问题标题】:AndroidActivity extends GameBaseActivity crashesAndroidActivity 扩展了 GameBaseActivity 崩溃
【发布时间】:2013-07-24 01:53:26
【问题描述】:

我正在上课

公共类 GameActivity 扩展了 Activity 实现 GLSurfaceView.Renderer, OnTouchListener{

代码没有任何问题,所有需要的方法都实现了。当我启动 Activity 时,它会崩溃并显示以下消息:

java.lang.RuntimeException:无法实例化活动 ComponentInfo{[遗漏].GameActivity}: java.lang.ClassNotFoundException:没有找到类“...GameActivity” 在路径 [...]

我想在我的游戏中集成 Google 游戏服务和成就。因此,我将 libary 项目和 GameBaseUtils 添加为项目,并检查它们是否应该导出到我生成的 apk 文件中。它编译,用于 google play 服务的 .jar 也被上传并会被发现。所有包括工作。但是当我开始游戏时,它立即崩溃并显示上述错误消息。

我按照developers.android.com https://developers.google.com/games/services/android/init上的教程进行操作

谁能告诉我我做错了什么?这是我的清单

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=""
android:versionCode="1"
android:versionName="1.0" >

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

<!-- 
  Tell the market, that the the app requires at least OpenGLES 2.0 
  This is not really the truth but it will decrease the rate of error
 -->
<uses-feature android:glEsVersion="0x00020000" 
    android:required="true" />

<!-- Maybe not neccessary -->
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/> -->


<application 
    android:allowBackup="true"
    android:icon="@drawable/launcher_icon"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:screenOrientation="sensorLandscape" >

    <meta-data android:name="com.google.android.gms.games.APP_ID"
    android:value="13465798" />


    <activity
        android:name="GameActivity"
        android:screenOrientation="sensorLandscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <!-- For the implementation of Adds in this App -->
</application>

</manifest>

编辑:定位输出

07-21 01:13:47.730: W/dalvikvm(22578): 无法解析超类 LGameActivity; (1182) 07-21 01:13:47.730: W/dalvikvm(22578): 类链接 'L/游戏活动;' 07-21 01:13:47.730 失败: D/AndroidRuntime(22578): 关闭 VM 07-21 01:13:47.730: W/dalvikvm(22578):threadid=1:线程以未捕获的异常退出 (组=0x4159f930)07-21 01:13:47.746:E/AndroidRuntime(22578):致命 例外:主要 07-21 01:13:47.746:E/AndroidRuntime(22578): java.lang.RuntimeException:无法实例化活动 组件信息{游戏活动}: java.lang.ClassNotFoundException:找不到类 路径上的“GameActivity”: .apk 07-21 01:13:47.746: E/AndroidRuntime(22578):在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106) 07-21 01:13:47.746: E/AndroidRuntime(22578): 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 07-21 01:13:47.746: E/AndroidRuntime(22578): 在 android.app.ActivityThread.access$600(ActivityThread.java:141) 07-21 01:13:47.746:E/AndroidRuntime(22578):在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 07-21 01:13:47.746: E/AndroidRuntime(22578): 在 android.os.Handler.dispatchMessage(Handler.java:99) 07-21 01:13:47.746:E/AndroidRuntime(22578):在 android.os.Looper.loop(Looper.java:137) 07-21 01:13:47.746: E/AndroidRuntime(22578):在 android.app.ActivityThread.main(ActivityThread.java:5041) 07-21 01:13:47.746:E/AndroidRuntime(22578):在 java.lang.reflect.Method.invokeNative(Native Method) 07-21 01:13:47.746:E/AndroidRuntime(22578):在 java.lang.reflect.Method.invoke(Method.java:511) 07-21 01:13:47.746: E/AndroidRuntime(22578):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 07-21 01:13:47.746: E/AndroidRuntime(22578): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 07-21 01:13:47.746:E/AndroidRuntime(22578):在 dalvik.system.NativeStart.main(Native Method) 07-21 01:13:47.746: E/AndroidRuntime(22578):引起:java.lang.ClassNotFoundException: 在路径上找不到类“GameActivity”: -1.apk 07-21 01:13:47.746: E/AndroidRuntime(22578):在 dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65) 07-21 01:13:47.746: E/AndroidRuntime(22578): 在 java.lang.ClassLoader.loadClass(ClassLoader.java:501) 07-21 01:13:47.746:E/AndroidRuntime(22578):在 java.lang.ClassLoader.loadClass(ClassLoader.java:461) 07-21 01:13:47.746:E/AndroidRuntime(22578):在 android.app.Instrumentation.newActivity(Instrumentation.java:1054) 07-21 01:13:47.746: E/AndroidRuntime(22578): 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 07-21 01:13:47.746: E/AndroidRuntime(22578): ... 11 更多

【问题讨论】:

  • 你能发布完整的 LogCat 吗?
  • 我已经添加了定位输出
  • 在清单中的 &lt;application&gt; 标记内,您是否尝试过类似的操作:&lt;activity android:name=.GameActivity" android:screenOrientation="sensorLandscape"&gt;
  • 这是由于尝试删除应用程序名称和包名称而导致的错误。在我的项目清单中,包和名称是正确的。我将编辑到原始清单

标签: android google-play-services


【解决方案1】:

我发现了错误:

我必须将我用于应用程序的两个项目(GameBaseUtils 和 google-play-services_lib)标记为库项目,并将它们添加到我想要使用的 android 库中。其余的由 android 自己处理。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多