libgdx项目构建但未运行(Android Studio)

时间:2017-01-22 11:51:13

标签: java android android-studio libgdx runtime-error

我的代码运行甚至项目构建,但是当我运行它时,我得到了这些错误,我似乎无法弄清楚要做什么。我已经在网上尝试了所有可能的答案,但事先似乎没有任何效果

 $ adb shell am start -n "com.buzz.dodge/com.buzz.dodge.AndroidLauncher" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 2324 on device Nexus_5_API_23 [emulator-5554]
I/art: Not late-enabling -Xcheck:jni (already on)
I/art: Debugger is no longer active
I/MultiDex: VM with version 2.1.0 has multidex support
I/MultiDex: install
I/MultiDex: VM has multidex support, MultiDex support library is disabled.

        [ 01-26 23:52:59.330  1546: 1569 D/         ]
        HostConnection::get() New Host Connection established 0x9c03e1c0, tid 1569
I/MultiDex: install
 I/MultiDex: VM has multidex support, MultiDex support library is disabled.
I/AdColony: ==== Configuring AdColony 2.2.2 ====
D/IAP: Creating IAB helper.
D/IAP: Starting setup.
D/IabHelper: Starting in-app billing setup.
D/IAP: Setup finished.
W/PopupManager: You have not specified a View to use as content view for     popups. Falling back to the Activity content view. Note that this may not work as expected in multi-screen environments
W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/x86
W/art: Suspending all threads took: 8.060ms
I/art: Background sticky concurrent mark sweep GC freed 5260(402KB) AllocSpace objects, 0(0B) LOS objects, 22% free, 2MB/3MB, paused 8.633ms total 75.896ms
D/ChimeraCfgMgr: Reading stored module config
D/ChimeraFileApk: Primary ABI of requesting process is x86
D/ChimeraFileApk: Classloading successful. Optimized code found.
D/DynamitePackage: Instantiated singleton DynamitePackage.
D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
I/WebViewFactory: Loading com.android.webview version 44.0.2403.119 (code 246011910)
W/System: ClassLoader referenced unknown path: /system/app/webview/lib/x86
I/LibraryLoader: Time to load native libraries: 4 ms (timestamps 2765-2769)
I/LibraryLoader: Expected native library version number "",actual native library version number ""
V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {b285285}
I/LibraryLoader: Expected native library version number "",actual native library version number ""
 I/chromium: [INFO:library_loader_hooks.cc(120)] Chromium logging enabled: level = 0, default verbosity = 0
I/BrowserStartupController: Initializing chromium process, singleProcess=true
W/art: Attempt to remove non-JNI local reference, dumping thread
W/art: Suspending all threads took: 15.708ms
D/hi: File /data/user/0/com.buzz.dodge/cache/1460683162801.dex not found. No need for deletion
I/art: Background sticky concurrent mark sweep GC freed 7119(957KB) AllocSpace objects, 8(560KB) LOS objects, 25% free, 4MB/6MB, paused 17.285ms total 122.343ms
E/SysUtils: ApplicationContext is null in ApplicationStatus
W/chromium: [WARNING:resource_bundle.cc(285)] locale_file_path.empty()
E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
W/AudioManagerAndroid: Requires BLUETOOTH permission
E/DataReductionProxySettingListener: No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
W/art: Long monitor contention event with owner method=void java.lang.Thread.nativeCreate(java.lang.Thread, long, boolean) from Thread.java:4294967294 waiters=0 for 7.943s
W/art: Long monitor contention event with owner method=void java.lang.Thread.nativeCreate(java.lang.Thread, long, boolean) from Thread.java:4294967294 waiters=1 for 7.944s
W/art: Long monitor contention event with owner method=void java.lang.Thread.nativeCreate(java.lang.Thread, long, boolean) from Thread.java:4294967294 waiters=2 for 7.944s
W/art: Long monitor contention event with owner method=void java.lang.Thread.nativeCreate(java.lang.Thread, long, boolean) from Thread.java:4294967294 waiters=3 for 7.944s
W/art: Long monitor contention event with owner method=void java.lang.Thread.nativeCreate(java.lang.Thread, long, boolean) from Thread.java:4294967294 waiters=4 for 7.940s
W/art: Long monitor contention event with owner method=void java.lang.Thread.nativeCreate(java.lang.Thread, long, boolean) from Thread.java:4294967294 waiters=5 for 7.939s
I/Ads: Starting ad request.
D/AppStreamingHelper: Creating delegate
I/DynamiteModule: Considering local module com.google.android.gms.piccard.dynamite:0 and remote module com.google.android.gms.piccard.dynamite:4
I/DynamiteModule: Selected remote version of com.google.android.gms.piccard.dynamite, version >= 4
W/VideoCapabilities: Unrecognized profile/level 0/0 for video/mpeg2
W/VideoCapabilities: Unrecognized profile/level 0/2 for video/mpeg2
W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
I/Ads: Starting ad request.
I/AndroidInput: sensor listener setup
I/AdColony: [ADC] AdColony resume called.
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
I/OpenGLRenderer: Initialized EGL, version 1.4

              [ 01-26 23:53:14.273  2324: 2509 D/         ]
              HostConnection::get() New Host Connection established 0xae4a86e0, tid 2509


              [ 01-26 23:53:14.317  2324: 2343 D/         ]
              HostConnection::get() New Host Connection established 0xae4a90a0, tid 2343
W/GL2JNIView: creating OpenGL ES 2.0 context
I/GL2: all initialized 2
I/AndroidGraphics: OGL renderer: Android Emulator OpenGL ES Translator (GeForce GTX 750 Ti/PCIe/SSE2)
I/AndroidGraphics: OGL vendor: Google (NVIDIA Corporation)
I/AndroidGraphics: OGL version: OpenGL ES 2.0 (4.5.0 NVIDIA 369.09)
I/AndroidGraphics: OGL extensions: GL_EXT_debug_marker GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint GL_OES_texture_float GL_OES_texture_float_linear GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_packed_depth_stencil GL_OES_vertex_half_float GL_OES_texture_npot GL_OES_rgb8_rgba8 ANDROID_EMU_CHECKSUM_HELPER_v1 
E/EGL_emulation: [getAttribValue] Bad attribute idx
E/EGL_emulation: tid 2343: eglGetConfigAttrib(631): error 0x3004 (EGL_BAD_ATTRIBUTE)
E/EGL_emulation: [getAttribValue] Bad attribute idx
E/EGL_emulation: tid 2343: eglGetConfigAttrib(631): error 0x3004 (EGL_BAD_ATTRIBUTE)
I/AndroidGraphics: framebuffer: (5, 6, 5, 0)
I/AndroidGraphics: depthbuffer: (24)
I/AndroidGraphics: stencilbuffer: (0)
I/AndroidGraphics: samples: (0)
I/AndroidGraphics: coverage sampling: (false)
I/AndroidGraphics: Managed meshes/app: { }
I/AndroidGraphics: Managed textures/app: { }
I/AndroidGraphics: Managed cubemap/app: { }
I/AndroidGraphics: Managed shaders/app: { }
I/AndroidGraphics: Managed buffers/app: { }
D/MediaPlayer: setSubtitleAnchor in MediaPlayer
D/MediaPlayer: setSubtitleAnchor in MediaPlayer
E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
I/OMXClient: Using client-side OMX mux.
I/OMXClient: Using client-side OMX mux.
I/OMXClient: Using client-side OMX mux.
I/OMXClient: Using client-side OMX mux.
I/GameScreen: Attached
I/GameWidth 1080.0: GameHeight 1920.0
I/ADS: false
I/GameScreen: show called
I/GameScreen: resize
I/ADS: false
D/AndroidRuntime: Shutting down VM


              --------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.buzz.dodge, PID: 2324
              java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
                  at com.google.android.gms.common.internal.zzj$zza.zzc(Unknown Source)
                  at com.google.android.gms.common.internal.zzj$zza.zzs(Unknown Source)
                  at com.google.android.gms.common.internal.zzj$zzc.zzoF(Unknown Source)
                  at com.google.android.gms.common.internal.zzj$zzb.handleMessage(Unknown Source)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:148)
                  at android.app.ActivityThread.main(ActivityThread.java:5417)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

申请已终止。

Android build.gradle

 android {
buildToolsVersion '22.0.1'
compileSdkVersion 22
defaultConfig {

    minSdkVersion 9
    targetSdkVersion 23
    // Enabling multidex support.
    multiDexEnabled true
}
dexOptions {
    preDexLibraries = false
}

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    instrumentTest.setRoot('tests')
}
 }/*
 // needed to add JNI shared libraries to APK when compiling on CLI
 tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniFolders = new HashSet<File>()
pkgTask.jniFolders.add(new File(projectDir, 'libs'))
 }*/
  // called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
 task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/x86/").mkdirs();

configurations.natives.files.each { jar ->
    def outputDir = null
    if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
    if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
    if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
    if (outputDir != null) {
        copy {
            from zipTree(jar)
            into outputDir
            include "*.so"
        }
    }
}
  }
  afterEvaluate {
tasks.matching {
    it.name.startsWith('dex')
}.each { dx ->
    if (dx.additionalParameters == null) {
        dx.additionalParameters = ['--multi-dex']
    } else {
        dx.additionalParameters += '--multi-dex'
    }
}
 }

 task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
    Properties properties = new Properties()
    localProperties.withInputStream { instr ->
        properties.load(instr)
    }
    def sdkDir = properties.getProperty('sdk.dir')
    if (sdkDir) {
        path = sdkDir
    } else {
        path = "$System.env.ANDROID_HOME"
    }
} else {
    path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.buzz.dodge/AndroidLauncher'
 }
 // sets up the Android Eclipse project, using the old Ant based build.
  eclipse {
// need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
    main {
        java.srcDirs "src", 'gen'
    }
}


classpath {
    plusConfigurations += [project.configurations.compile]
    containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}

project {
    name = appName + "-android"
    natures 'com.android.ide.eclipse.adt.AndroidNature'
    buildCommands.clear();
    buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
    buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
    buildCommand "org.eclipse.jdt.core.javabuilder"
    buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
  }
  // sets up the Android Idea project, using the old Ant based build.
   idea {
module {
    sourceDirs += file("src");
    scopes = [COMPILE: [plus: [project.configurations.compile]]]

    iml {
        withXml {
            def node = it.asNode()
            def builder = NodeBuilder.newInstance();
            builder.current = node;
            builder.component(name: "FacetManager") {
                facet(type: "android", name: "Android") {
                    configuration {
                        option(name: "UPDATE_PROPERTY_FILES", value: "true")
                    }
                }
            }
        }
    }
}
}
dependencies {
compile 'com.google.android.gms:play-services-analytics:7.3.0'
}

AD Colony

  //AD COLONY

private void loadVideoStuff() {
    AdColony.configure(this, "version:1.0,store:google", APP_ID, ZONE_ID);
    if (!AdColony.isTablet()) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    AdColony.addV4VCListener(this);
    AdColony.addAdAvailabilityListener(this);
}

@Override
public void onAdColonyAdAttemptFinished(AdColonyAd adColonyAd) {
    Log.d("AdColony", "onAdColonyAdAttemptFinished");
}

@Override
public void onAdColonyAdStarted(AdColonyAd adColonyAd) {
    Log.d("AdColony", "onAdColonyAdStarted");
}

@Override
public void onAdColonyV4VCReward(AdColonyV4VCReward reward) {
    if (reward.success()) {
        startGameWithPuntuation();
    }
}

@Override
public void onAdColonyAdAvailabilityChange(boolean b, String s) {
    if (b) GameWorld.getMenu().getGameOver().getFreeButton().getSprite().setAlpha(1f);
    else GameWorld.getMenu().getGameOver().getFreeButton().getSprite().setAlpha(0f);
}

@Override
public void checkVideoAd() {
    AdColonyV4VCAd ad = new AdColonyV4VCAd(ZONE_ID);
    if (!ad.isReady()) {
        if (GameWorld.getMenu().getGameOver() != null) {
            GameWorld.getMenu().getGameOver().removeFreeButton();
        }else{
            GameWorld.getMenu().getGameOver().appearFreeButton();
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我认为你错过了.so文件。在android模块中找到libs文件夹。 Libs文件夹包含用于不同体系结构的.so文件。将所需的.so文件放在libs中。

正如你所提到的.so文件存在于libs文件夹中。

添加

jniLibs.srcDirs = ['libs']
在sourceSets标签中

,之后你的sourceSets看起来像这样

sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }

        instrumentTest.setRoot('tests')
    }

可能会解决您的问题。

当我检查你的build.gradle时,只生成3种类型的.so文件(针对3种不同的架构)。现在在最新版本的libgdx中,它支持5种架构(armeabi,armeabi-v7a,arm64-v8a,x86_64,x86)。

因此最好使用最新版本的libgdx 1.9.5更新您的项目。

编辑2

我检查你是否使用了multidex支持但没有编译dex jar文件 在你的android build.gradle

中添加这个依赖项
compile 'com.android.support:multidex:1.0.1'