【问题标题】:Android app won't start (displays a black screen) on Nexus 7Android 应用无法在 Nexus 7 上启动(显示黑屏)
【发布时间】:2014-05-25 04:32:46
【问题描述】:

我正在使用 Gameplay3D 编写一个 Android 应用程序。我可以使用 NDK 编译并使用 ANT 生成 APK(调试和发布)。该应用程序可以在 Galaxy S3 和 Nexus 4 上完美安装、启动和运行,但是当我尝试在 Nexus 7 上启动它时,它什么也不显示。只是黑屏,底部有导航栏。

我有两台 Nexus 7,每台都有不同的 Android 版本(一个是 4.3,另一个是 4.4)。

我对 Android 开发的经验并不丰富,但这是我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.secretCompany.secretGame"
        android:versionCode="15"
        android:versionName="1.0.0">

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!-- This is the platform API where the app was introduced. -->
    <uses-sdk android:minSdkVersion="10" />
    <uses-feature android:glEsVersion="0x00020000"/>

    <application android:icon="@drawable/icon" android:label="@string/app_name" android:hasCode="true">

        <!-- Our activity is the built-in NativeActivity framework class.
             This will take care of integrating with our NDK code. -->
        <activity android:name="android.app.NativeActivity"
                android:label="@string/app_name"
                android:configChanges="orientation|keyboardHidden"
                android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                android:screenOrientation="landscape">
            <!-- Tell NativeActivity the name of or .so -->
            <meta-data android:name="android.app.lib_name"
                    android:value="secretGame" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest> 

我已经更改了游戏的名称和公司,因为它们目前是一个秘密,但除此之外,这正是它在文件中的显示方式。

任何帮助将不胜感激:)

其他信息:

应用程序唯一要做的就是渲染精灵并接受输入。没有声音,没有互联网,没有别的。

两个 Nexuses (Nexi?:P) 都是 2012 版,而不是新的 2013 版。

我使用渲染到纹理。这会是个问题吗?也许使用非 2 次幂纹理?

我测试了,代码还在运行,就是什么都看不到。

【问题讨论】:

    标签: android c++ ant android-ndk nexus-7


    【解决方案1】:

    终于,我自己从this post 弄明白了。问题是我几乎所有的纹理都不是 2 的幂次方,而且当时不在屏幕上。

    我真傻。

    编辑: 或者可能不会...现在它不会显示任何内容,甚至之前的 2 次幂纹理也不会显示...OpenGL FBO 是否必须有一个正方形纹理可以在 2 次幂设备上工作?

    Edit2:啊,好的,我终于找到了问题所在。最初我对没有 2 次幂纹理的精灵是正确的,但后来我重新启用了我的渲染到纹理并且它停止了工作。原来问题是我正在渲染到不同的 FBO,然后提取纹理以将其转换为精灵并渲染到主 FBO ......当然,纹理不是 2 的幂。我刚刚创建了整个屏幕仍然适合的最低 PO2 尺寸的纹理,然后修改了全屏精灵的 UV 坐标,以便将额外的纹理部分放在屏幕外。问题解决了!

    【讨论】:

    • ES 2.0 基本上支持 NPOT(non-power-of-2)纹理,但主要限制在 wrap 模式和 mipmapping。如果支持 OES_texture_npot 扩展,这些限制就会被解除。这可能解释了为什么您的代码在某些设备上有效,而在其他设备上无效。失败的设备很可能不支持此扩展。
    • @RetoKoradi 啊,我明白了,谢谢。好吧,这不再重要了,因为我创建了一个系统,将它们加载为下一个最大尺寸的 POT,然后使用 UV 坐标以正确的尺寸渲染它们:)
    • 我会接受我自己的答案,但我必须等待 2 天才能做到这一点;)
    猜你喜欢
    • 2014-12-25
    • 2013-04-06
    • 2014-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-26
    相关资源
    最近更新 更多