2017-06-13 55 views
0

我为我的应用程序创建了一个启动屏幕,它运行良好,但是在其他设备上测试时,如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:[email protected]') { 
     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:[email protected]' 
    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

@Joe C没有它只是闪屏崩溃 – Nativony

+1

@Nativony他的意思是应用程序崩溃后的logcat错误是什么? – DaveNOTDavid

回答

0

安装(或任何所得)版本N和O SDK包,如果你还没有这样做的话:

  • 的Android SDK平台
  • 谷歌API的英特尔凌动x86的系统映像
  • 的Android模拟器
  • Android SDK工具
  • 的Android SDK平台的工具
+0

正在尝试安装模拟器nexus api 26知道logCat错误究竟是什么@DaveNOTDavid – Nativony

+0

@Nativony如果您想严格测试O,那么您必须先重新配置您的本地build.gradle文件...此资源可能有帮助:https://developer.android.com/preview/migration.html – DaveNOTDavid

相关问题