Java这个错误是什么意思?

时间:2016-01-17 22:42:19

标签: java android sdl

这与之前的问题类似,但我想确保我确实知道此错误的含义:

01-17 23:55:23.828: I/dalvikvm(31248): Could not find method com.company.game.GameActivity.onActivityResultGameActivity, referenced from method com.company.game.GameActivity.onActivityResult
01-17 23:55:23.828: W/dalvikvm(31248): VFY: unable to resolve direct method 1973: Lcom/company/game/GameActivity;.onActivityResultGameActivity (IILandroid/content/Intent;)V
01-17 23:55:23.828: D/dalvikvm(31248): VFY: replacing opcode 0x70 at 0x0007
01-17 23:55:23.828: I/dalvikvm(31248): Could not find method com.company.game.GameActivity.onCreateGameActivity, referenced from method com.company.game.GameActivity.onCreate
01-17 23:55:23.828: W/dalvikvm(31248): VFY: unable to resolve direct method 1979: Lcom/company/game/GameActivity;.onCreateGameActivity (Landroid/os/Bundle;)V
01-17 23:55:23.828: D/dalvikvm(31248): VFY: replacing opcode 0x70 at 0x0000
01-17 23:55:23.828: I/dalvikvm(31248): Could not find method com.company.game.GameActivity.onCreateDialogGameActivity, referenced from method com.company.game.GameActivity.onCreateDialog
01-17 23:55:23.828: W/dalvikvm(31248): VFY: unable to resolve direct method 1977: Lcom/company/game/GameActivity;.onCreateDialogGameActivity (I)Landroid/app/Dialog;
01-17 23:55:23.828: D/dalvikvm(31248): VFY: replacing opcode 0x70 at 0x0008
01-17 23:55:23.828: I/dalvikvm(31248): Could not find method com.company.game.GameActivity.onCreateDialogGameActivity, referenced from method com.company.game.GameActivity.onCreateDialog
01-17 23:55:23.828: W/dalvikvm(31248): VFY: unable to resolve direct method 1978: Lcom/company/game/GameActivity;.onCreateDialogGameActivity (ILandroid/os/Bundle;)Landroid/app/Dialog;
01-17 23:55:23.828: D/dalvikvm(31248): VFY: replacing opcode 0x70 at 0x0008
01-17 23:55:23.828: I/dalvikvm(31248): Could not find method com.company.game.GameActivity.onDestroyGameActivity, referenced from method com.company.game.GameActivity.onDestroy
01-17 23:55:23.828: W/dalvikvm(31248): VFY: unable to resolve direct method 1981: Lcom/company/game/GameActivity;.onDestroyGameActivity ()V
01-17 23:55:23.828: D/dalvikvm(31248): VFY: replacing opcode 0x70 at 0x0000
01-17 23:55:23.835: I/dalvikvm(31248): Could not find method com.company.game.GameActivity.onPauseGameActivity, referenced from method com.company.game.GameActivity.onPause
01-17 23:55:23.835: W/dalvikvm(31248): VFY: unable to resolve direct method 1983: Lcom/company/game/GameActivity;.onPauseGameActivity ()V
01-17 23:55:23.835: D/dalvikvm(31248): VFY: replacing opcode 0x70 at 0x0000
01-17 23:55:23.835: I/dalvikvm(31248): Could not find method com.company.game.GameActivity.onResumeGameActivity, referenced from method com.company.game.GameActivity.onResume
01-17 23:55:23.835: W/dalvikvm(31248): VFY: unable to resolve direct method 1985: Lcom/company/game/GameActivity;.onResumeGameActivity ()V
01-17 23:55:23.835: D/dalvikvm(31248): VFY: replacing opcode 0x70 at 0x0000
01-17 23:55:23.835: I/dalvikvm(31248): Could not find method com.company.game.GameActivity.onStartGameActivity, referenced from method com.company.game.GameActivity.onStart
01-17 23:55:23.835: W/dalvikvm(31248): VFY: unable to resolve direct method 1987: Lcom/company/game/GameActivity;.onStartGameActivity ()V
01-17 23:55:23.835: D/dalvikvm(31248): VFY: replacing opcode 0x70 at 0x0000
01-17 23:55:23.835: I/dalvikvm(31248): Could not find method com.company.game.GameActivity.onStopGameActivity, referenced from method com.company.game.GameActivity.onStop
01-17 23:55:23.835: W/dalvikvm(31248): VFY: unable to resolve direct method 1989: Lcom/company/game/GameActivity;.onStopGameActivity ()V
01-17 23:55:23.835: D/dalvikvm(31248): VFY: replacing opcode 0x70 at 0x0000
01-17 23:55:23.835: D/dalvikvm(31248): Trying to load lib /data/data/com.company.game/lib/libSDL2.so 0x415e7228
01-17 23:55:23.835: D/dalvikvm(31248): Added shared lib /data/data/com.company.game/lib/libSDL2.so 0x415e7228
01-17 23:55:23.835: D/dalvikvm(31248): Trying to load lib /data/data/com.company.game/lib/libSDL2_ttf.so 0x415e7228
01-17 23:55:23.843: D/dalvikvm(31248): Added shared lib /data/data/com.company.game/lib/libSDL2_ttf.so 0x415e7228
01-17 23:55:23.843: D/dalvikvm(31248): No JNI_OnLoad found in /data/data/com.company.game/lib/libSDL2_ttf.so 0x415e7228, skipping init
01-17 23:55:23.843: D/dalvikvm(31248): Trying to load lib /data/data/com.company.game/lib/libmain.so 0x415e7228
01-17 23:55:23.843: D/dalvikvm(31248): Added shared lib /data/data/com.company.game/lib/libmain.so 0x415e7228
01-17 23:55:23.843: D/dalvikvm(31248): No JNI_OnLoad found in /data/data/com.company.game/lib/libmain.so 0x415e7228, skipping init
01-17 23:55:23.859: D/AndroidRuntime(31248): Shutting down VM
01-17 23:55:23.859: W/dalvikvm(31248): threadid=1: thread exiting with uncaught exception (group=0x40b06228)
01-17 23:55:23.859: E/AndroidRuntime(31248): FATAL EXCEPTION: main
01-17 23:55:23.859: E/AndroidRuntime(31248): java.lang.NoSuchMethodError: com.company.game.GameActivity.onCreateGameActivity
01-17 23:55:23.859: E/AndroidRuntime(31248):    at com.company.game.GameActivity.onCreate(GameActivity.java)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at android.app.Activity.performCreate(Activity.java:4635)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1999)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2060)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1181)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at android.os.Looper.loop(Looper.java:137)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at android.app.ActivityThread.main(ActivityThread.java:4558)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at java.lang.reflect.Method.invokeNative(Native Method)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at java.lang.reflect.Method.invoke(Method.java:511)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-17 23:55:23.859: E/AndroidRuntime(31248):    at dalvik.system.NativeStart.main(Native Method)
01-17 23:55:23.984: D/dalvikvm(207): GC_CONCURRENT freed 346K, 25% free 17868K/23559K, paused 2ms+5ms
01-17 23:55:23.992: D/AmazonToggle(300): setText toggle_on
01-17 23:55:23.992: D/AmazonToggle(300): setText toggle_off
01-17 23:55:24.000: D/QuickSettings-Wifi(300): handleSelection Begin
01-17 23:55:24.062: W/ActivityManager(207):   Force finishing activity com.company.game/.GameActivity

(GameActivity是一个扩展SDLActivity的类,它扩展了Activity)。 我认为这意味着它正在寻找一种名为' com.company.game.GameActivity.onCreateGameActivity'

的方法

这是一个非常奇怪的方法,因为它应该被称为com.company.game.GameActivity.onCreate ......

我只是想确保这实际上是错误意味着什么 - 如果这就是它意味着我完全难倒,我不知道为什么它会将GameActivity附加到方法名称。 (这只发生在一些Android设备上 - 在其他人的应用程序运行良好,没有任何错误...)

修改 这是我的GameActivity:

package com.company.game;

import org.libsdl.app.*;
import android.os.Bundle;
import android.util.Log;

import com.google.android.gms.ads.*;

/**
 * Game Activity
 */
public class GameActivity extends SDLActivity {

    // Interstiatial advert
    public static InterstitialAd mInterstitialAd;
    public static boolean mShowingInterstitial;
    public static void showInterstitial() {
        Log.v("SDL", "Attempting to Show Iterstitial!");
        mShowingInterstitial = true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Interstitial advert
        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("Ad id here");

        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdClosed() {
                AdRequest adRequest = new AdRequest.Builder().build();
                mInterstitialAd.loadAd(adRequest);
            }

            @Override
            public void onAdFailedToLoad(int errorCode) {
                AdRequest adRequest = new AdRequest.Builder().build();
                mInterstitialAd.loadAd(adRequest);
            }
        });

        AdRequest adRequest = new AdRequest.Builder().build();
        mInterstitialAd.loadAd(adRequest);
    }
}

清单:

<?xml version="1.0" encoding="utf-8"?>
<!-- Replace org.libsdl.app with the identifier of your game below, e.g.
     com.gamemaker.game
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.company.game"
      android:versionCode="4"
      android:versionName="1.0.3"
      android:installLocation="auto">


    <!-- Minimum Android 4.0.3 Target Android 5.0 -->
    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="21"/>

    <!-- OpenGL ES 2.0 -->
    <uses-feature android:glEsVersion="0x00020000" /> 

    <!-- Permissions --> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>



    <application android:label="Game"
                 android:icon="@drawable/ic_launcher"
                 android:allowBackup="true"
                 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                 android:hardwareAccelerated="true" >

        <meta-data android:name="com.google.android.gms.version"
                   android:value="@integer/google_play_services_version" />

        <activity android:name="GameActivity"
                  android:label="Game"
                  android:configChanges="keyboardHidden|orientation"
                  android:screenOrientation="sensorLandscape"
                  >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Translucent" />

    </application>

</manifest> 

我的SDLActivity是SDL 2.0.4的SDLActivity

2 个答案:

答案 0 :(得分:1)

您的stacktrace提供了足够的信息,

  

01-17 23:55:23.835:D / dalvikvm(31248):试图加载lib   /data/data/com.company.game/lib/libSDL2.so 0x415e7228 01-17   23:55:23.835:D / dalvikvm(31248):添加了共享库   /data/data/com.company.game/lib/libSDL2.so 0x415e7228 01-17   23:55:23.835:D / dalvikvm(31248):尝试加载lib   /data/data/com.company.game/lib/libSDL2_ttf.so 0x415e7228 01-17   23:55:23.843:D / dalvikvm(31248):添加了共享库   /data/data/com.company.game/lib/libSDL2_ttf.so 0x415e7228 01-17   23:55:23.843:D / dalvikvm(31248):没有找到JNI_OnLoad   /data/data/com.company.game/lib/libSDL2_ttf.so 0x415e7228,跳过   init 01-17 23:55:23.843:D / dalvikvm(31248):尝试加载lib   /data/data/com.company.game/lib/libmain.so 0x415e7228 01-17   23:55:23.843:D / dalvikvm(31248):添加了共享库   /data/data/com.company.game/lib/libmain.so 0x415e7228 01-17   23:55:23.843:D / dalvikvm(31248):没有找到JNI_OnLoad   /data/data/com.company.game/lib/libmain.so 0x415e7228,跳过init   01-17 23:55:23.859:D / AndroidRuntime(31248):关闭虚拟机

您尝试加载的JNI库存在一些问题。 导致从JNIlibs调用任何本机函数导致NoSuchMethodError。

奇怪的事情:

  

01-17 23:55:23.859:E / AndroidRuntime(31248):   java.lang.NoSuchMethodError:   com.company.game.GameActivity.onCreateGameActivity 01-17 23:55:23.859:   E / AndroidRuntime(31248):at   com.company.game.GameActivity.onCreate(GameActivity.java)

应该提供行号,它崩溃了。

答案 1 :(得分:0)

这是重要的一句话:

01-17 23:55:23.859: E/AndroidRuntime(31248): java.lang.NoSuchMethodError: com.company.game.GameActivity.onCreateGameActivity

你有一个NoSuchMethodError意味着你的程序/应用程序试图在类GameActivity中调用不存在的方法onCreateGameActivity。

NoSuchMethodError in the Java Documentation

如果没有代码,我们无法告诉您为什么会抛出此异常。