-4

[This is when app start][1] [This is after open a Activity or make some action, memory keep up 460mb and more][2]2

this is my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nexttip.personaltrainer">

    <!-- Permisos de la aplicaion -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <application
        android:allowBackup="true"
        android:hardwareAccelerated="false"
        android:largeHeap="true"
        android:name="android.support.multidex.MultiDexApplication"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@drawable/ic_launcher"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <!-- Splash Screen -->
        <activity
            android:name=".SplashScreenActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity android:name=".DonateMainLayout" />
        <activity android:name=".VideoListActivity" />
        <activity
            android:name=".VideoActivity"
            android:screenOrientation="landscape"
            android:theme="@style/videoPlayer" />
        <activity android:name=".RateActivity" />

        <meta-data
            android:name="preloaded_fonts"
            android:resource="@array/preloaded_fonts" />

        <activity android:name=".BMI" />
        <activity android:name=".Result_BMI" />
        <activity
            android:name=".Video_Stream"
            android:screenOrientation="landscape"
            android:theme="@style/videoStream" />
        <activity
            android:name=".Timer_CountDown"
            android:theme="@style/AppTheme.Transparent" />
        <activity
            android:name=".ActivityList1"
            android:label="@string/list1_label" />
        <activity
            android:name=".ActivityList2"
            android:label="@string/list2_label" />
        <activity
            android:name=".ActivityList3"
            android:label="@string/list3_label" />
        <activity
            android:name=".ActivityList4"
            android:label="@string/list4_label" />
        <activity
            android:name=".ActivityList5"
            android:label="@string/list5_label">

        </activity>
        <activity
            android:name=".IntroActivity"
            android:label="@string/intro_title">

        </activity>
        <activity
            android:name=".TipsActivity"
            android:label="@string/tips_title">

        </activity>
        <activity android:name=".DietPlanMain"
            android:label="@string/diet_title">

        </activity>
    </application>

</manifest>

this is my gradle:

    apply plugin: 'com.android.application'
repositories {
    maven {
        url 'https://maven.google.com'
    }
}
android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.nexttip.personaltrainer"
        minSdkVersion 19
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'me.itangqi.waveloadingview:library:0.3.5'
    compile 'com.android.support:support-compat:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.android.gms:play-services-ads:11.8.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.android.support:multidex:1.0.0'
}
apply plugin: 'com.google.gms.google-services'

In the application I have some videos in an array and others that are loaded from a server, I also use gif images and other resources. I have already compressed the resources to see if I have no problems but when running the application on a mobile with less range, it closes with the memory error insufficient. I use a Samung s7 for tests with 4gb of ram and even so when changing activity makes it slow. Please Help me

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Sthim
  • 3
  • 3

1 Answers1

2

you should not keep an array of videos in your application. Instead you can keep the paths and url to video files and load only one video at a time which is needed to be played. Also try to use image caching library such as Picasso or Glide, they will take care of memory problems for large images too.

Fahed Yasin
  • 400
  • 2
  • 9