0

I developed a game app and it works really well for me and on my emulator in Android studio. I shared it with some friends and to some it works good and other friends they have problem especially when moving to another activity. All have lower Android version and the phone is old. But I don't know why it happens because when I started to do this project I made sure the language is Java and the minimum SDK is API 15: Android 4.0.3! So my guess is that there is something wrong with the code, maybe there is something which only newer version of Android can handle?

To switch an activity I use this

Intent intent = new Intent(this, MainActivity.class);// New activity
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        finish(); // Call once you redirect to another activity

All activity extends a BaseActivity!

I use this here to have FULLSCREEN! Is this the reason?

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    private void hideSystemUI() {
        // Enables regular immersive mode.
        // For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
        // Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                        // Set the content to appear under the system bars so that the
                        // content doesn't resize when the system bars hide and show.
                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        // Hide the nav bar and status bar
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN);
    }

    // Shows the system bars by removing all the flags
// except for the ones that make the content appear under the system bars.
    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    private void showSystemUI() {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }

Because of this annotation @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)

This is the setting of my build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "com.example.japan"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Here is the Error

2020-04-11 10:30:25.762 6577-6577/com.example.japan E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.japan, PID: 6577
    java.lang.RuntimeException: Canvas: trying to draw too large(132710400bytes) bitmap.
        at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260)
        at android.graphics.Canvas.drawBitmap(Canvas.java:1420)
        at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545)
        at android.widget.ImageView.onDraw(ImageView.java:1286)
        at android.view.View.draw(View.java:18318)
        at android.view.View.updateDisplayListIfDirty(View.java:17296)
        at android.view.View.draw(View.java:18080)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
        at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
        at android.view.View.draw(View.java:18321)
        at android.view.View.updateDisplayListIfDirty(View.java:17296)
        at android.view.View.draw(View.java:18080)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
        at android.view.View.updateDisplayListIfDirty(View.java:17291)
        at android.view.View.draw(View.java:18080)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
        at android.view.View.updateDisplayListIfDirty(View.java:17291)
        at android.view.View.draw(View.java:18080)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
        at android.view.View.updateDisplayListIfDirty(View.java:17291)
        at android.view.View.draw(View.java:18080)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
        at android.view.View.updateDisplayListIfDirty(View.java:17291)
        at android.view.View.draw(View.java:18080)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
        at android.view.View.draw(View.java:18321)
        at com.android.internal.policy.DecorView.draw(DecorView.java:919)
        at android.view.View.updateDisplayListIfDirty(View.java:17296)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:692)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:698)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:806)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:3128)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2924)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2516)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1515)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7091)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
        at android.view.Choreographer.doCallbacks(Choreographer.java:702)
        at android.view.Choreographer.doFrame(Choreographer.java:638)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6682)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
hata
  • 11,633
  • 6
  • 46
  • 69
Takuya2412
  • 187
  • 10
  • Please [edit] your question to provide the complete [stack trace from the crash](https://stackoverflow.com/a/23353174). – Mike M. Apr 11 '20 at 08:11
  • Hi, I can't reproduce the error as it runs perfectly fine on Android Studio.. it's only on some devices of my friends (App has stopped) – Takuya2412 Apr 11 '20 at 08:15
  • Borrow one of your friends' devices, hook it up to your development machine to run your app on it, and have a look at the logs. – Mike M. Apr 11 '20 at 08:17
  • I ran your code and there is no problem with it. It must be from your friend's device. – Arrowsome Apr 11 '20 at 08:17
  • Fortunately I have an old android phone Samsung Galaxy S6 which has Android 7.0! I can't even install the app on the phone... So it must be something with the version I guess.. I activated developer mode and USB-Debugging but for some reason my PC does not recognize the old phone.. – Takuya2412 Apr 11 '20 at 08:27
  • Hey Mike! I added the stack trace! Could you take a look?? – Takuya2412 Apr 11 '20 at 08:31
  • `Canvas: trying to draw too large(132710400bytes) bitmap.` – You've got an image set on an `ImageView` somewhere that's just too big for those devices. – Mike M. Apr 11 '20 at 08:34
  • Ah thanks. Is there a solution? Delete? Compress? Is there a way to find out which ImageView? Since this game is a text adventure and has lots of ImageViews :( – Takuya2412 Apr 11 '20 at 08:36
  • @Takuya2412 Recently, I answered a similar problem of yours. https://stackoverflow.com/q/61134238/3501958 After scale down your bitmap, and `setImageBitmap` to the target ImageView. – hata Apr 11 '20 at 08:42
  • Thanks guys! I moved the images to drawable-xxhdpi it works but not sure if this is the best solution – Takuya2412 Apr 11 '20 at 08:57

0 Answers0