简体   繁体   English

java.lang.RuntimeException:createContext失败:

[英]java.lang.RuntimeException: createContext failed:

I am using Emulator 7.1.1(Google Apis) . 我正在使用Emulator 7.1.1(Google Apis) Full exception is 完全例外是

     E/AndroidRuntime: FATAL EXCEPTION: GLThread 309

 java.lang.RuntimeException: createContext failed: 12291
  at com.google.maps.api.android.lib6.gmm6.vector.bi.a(:com.google.android.gms.DynamiteModulesB:834)
  at com.google.maps.api.android.lib6.gmm6.vector.bj.f(:com.google.android.gms.DynamiteModulesB:20825)
  at com.google.maps.api.android.lib6.gmm6.vector.bj.run(:com.google.android.gms.DynamiteModulesB:881)

The code is working fine on samsung galaxy J5 but not working on emulator . 该代码在samsung galaxy J5上运行正常,但在emulator上却无法运行。 I have searched on google & my 2 hours wasted on this error & still not able to find the solution. 我已经在Google上进行了搜索,而我在此错误上浪费了2个小时,但仍然找不到解决方案。 Any help will be appreciated. 任何帮助将不胜感激。

My build.gradle file: 我的build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    dexOptions {
        javaMaxHeapSize "4g"
    }

    defaultConfig {
        applicationId "com.katariya.pomoc"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        renderscriptTargetApi 18
        renderscriptSupportModeEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:design:25.3.0'
    compile 'com.android.support:recyclerview-v7:25.3.0'
    compile 'com.google.android.gms:play-services-maps:10.2.1'
    compile 'com.google.android.gms:play-services-location:10.2.1'
    compile 'com.google.android.gms:play-services-gcm:10.2.1'
    compile 'com.google.firebase:firebase-core:10.2.1'
    compile 'com.google.firebase:firebase-messaging:10.2.1'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.android.support:support-v4:25.3.0'
    compile 'com.android.support:multidex:1.0.0'
    compile 'commons-io:commons-io:2.4'

}
apply plugin: 'com.google.gms.google-services'

I got it! 我知道了!

I went into the settings of the emulator itself and changed OpenGL ES render from Autodetect based on host (default) to Desktop native OpenGL . 我进入了模拟器本身的设置,并将OpenGL ES渲染基于主机的Autodetect(默认值)更改为Desktop native OpenGL After that my app began working perfectly. 之后,我的应用程序开始完美运行。 Here is a screenshot for clarity, hope this helps somebody in the future! 这是一个清晰的屏幕截图,希望这对以后有所帮助!

在此处输入图片说明

When creating a new Emulator one can choose some options in Emulated performance. 创建新的仿真器时,可以在“仿真性能”中选择一些选项。 It may be Automatic , Hardware GLES or Software GLES . 它可以是自动硬件GLES软件GLES In my case Software GLES 2.0 did the magic. 以我为例,软件GLES 2.0发挥了神奇作用。 The maps are working a little bit slower but fast enough to have patience to try my app out. 这些地图的运行速度稍慢一些,但足够快,可以耐心尝试我的应用程序。

Here's the picture of place where to choose Emulation for Graphics 这是选择“图形仿真”的地方的图片 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM