飞溅屏幕崩溃在某些设备上

时间:2017-06-13 21:59:13

标签: java android

我为我的应用程序创建了一个启动画面它运行良好,但是我正在测试其他设备,如nougat软件它崩溃我不知道为什么我将目标SDK从版本25更改为26但它也崩溃了 这是我的Splash.java

package mediaclub.app.paymob;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class Splash extends AppCompatActivity {

    public static final String PREF_FILE_NAME = "mediaclub.app.paymob.preferences";
    public static final String KEY_BALANCE = "balance";
    public static final String KEY_MOBILE_NUMBER = "mobile_number";
    public static final String KEY_FIRST = "first_time";
    Boolean first;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        first = Boolean.valueOf(readFromPreferences(Splash.this, KEY_FIRST, "true"));

        Runnable mRunnable;
        Handler mHandler = new Handler();

//        if (!gps.canGetLocation()) {
//            gps.showSettingsAlert();
//        }

        try {
            mRunnable = new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    if (first) {
                        Intent i = new Intent(Splash.this, RegisterActivity.class);
                        startActivity(i);
                    } else {
                        Intent i = new Intent(Splash.this, SignInActivity.class);
//                    Intent i = new Intent(Splash.this, MainActivity.class);
                        startActivity(i);
                    }
                }
            };

            mHandler.postDelayed(mRunnable, 3 * 1000);

        }catch (Exception e){
            Intent i = new Intent(Splash.this, SignInActivity.class);
//                    Intent i = new Intent(Splash.this, MainActivity.class);
            startActivity(i);

        }
    }

    public static void saveToPreferences(Context context, String preferenceName, String preferenceValue) {

        SharedPreferences sharedPreferences = context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(preferenceName, preferenceValue);
        editor.apply();
    }

    public static String readFromPreferences(Context context, String preferenceName, String defaultValue) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE);
        return sharedPreferences.getString(preferenceName, defaultValue);
    }
}

这是build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

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

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "mediaclub.app.cashati"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.crashlytics.sdk.android:crashlytics:2.6.4@aar') {
        transitive = true;
    }
    //Glide
    compile 'com.google.firebase:firebase-messaging:9.4.0'
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.google.firebase:firebase-messaging:9.4.0'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.mikhaellopez:circularimageview:3.0.2'
    compile 'me.dm7.barcodescanner:zxing:1.8.4'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.soundcloud.android:android-crop:1.0.1@aar'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'io.realm:realm-android:0.87.5'
    compile 'com.github.BlacKCaT27:CurrencyEditText:v1.3.1'
    compile 'com.felipecsl:gifimageview:2.0.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.16'
    compile 'cn.pedant.sweetalert:library:1.3'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    testCompile 'junit:junit:4.12'
    compile project(path: ':datetimepickeredittext')
}

apply plugin: 'com.google.gms.google-services'
请一些人帮我解决这个案子,希望这个可以说得够清楚

1 个答案:

答案 0 :(得分:0)

如果您尚未安装(或任何)版本N和O的以下SDK软件包:

  • Android SDK平台
  • Google API英特尔x86 Atom系统映像
  • Android模拟器
  • Android SDK工具
  • Android SDK平台工具