2017-06-15 5 views
1

Logcatファイルをクラッシュさ: -Androidアプリのエラーアプリはしばらくinstallattion

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.nxtgendataingestion/com.example.android.nxtgendataingestion.SplashScreen}: java.lang.IllegalArgumentException: Unknown color 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483) 
    at android.app.ActivityThread.access$900(ActivityThread.java:153) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5438) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628) 
Caused by: java.lang.IllegalArgumentException: Unknown color 
    at android.graphics.Color.parseColor(Color.java:226) 
    at com.example.android.nxtgendataingestion.SplashScreen.onCreate(SplashScreen.java:24) 
    at android.app.Activity.performCreate(Activity.java:6303) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376) 
    ... 9 more 

SplashScreen.java:-

package com.example.android.nxtgendataingestion; 

import android.graphics.Color; 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.view.View; 

import gr.net.maroulis.library.EasySplashScreen; 

public class SplashScreen extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     EasySplashScreen config = new EasySplashScreen(SplashScreen.this) 
       .withFullScreen() 
       .withTargetActivity(MainActivity.class) 
       .withSplashTimeOut(5000) 
       .withBackgroundColor(Color.parseColor("#ebedef")) 
       .withHeaderText("WELCOME") 
       .withAfterLogoText("Tour Guide App"); 
     //Set Text Color 
     config.getHeaderTextView().setTextColor(android.graphics.Color.parseColor("#239b56f")); 
     config.getAfterLogoTextView().setTextColor(android.graphics.Color.parseColor("#239b56f")); 
     View view = config.create(); 
     setContentView(view); 


    } 
} 

グレードファイル: -

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.example.android.nxtgendataingestion" 
     minSdkVersion 15 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    testCompile 'junit:junit:4.12' 
    //Add Librry of Splash Screen 
    compile 'gr.pantrif:easy-android-splash-screen:0.0.1' 
} 

私はアプリをインストール私はアプリのアイコンをクリックするとスマートフォンがクラッシュする。私はエラーがカラーコードにあると思うが、私はそれを並べ替えることができないと思う。私はこの答えについてインターネットを掘るしかし有効な答えが出ていません。それを並べ替えることを助けてください。事前にお礼します。

+2

うん、あなたの色が悪いです '#の239b56f'は、' int型のアルファ、int型の赤、緑int型でなければなりませんint型blue'#11223344' –

+0

読むhttps://developer.android.com/reference/android 'ので、 /graphics/Color.html#parseColor(java.lang.String) –

答えて

1

問題

android.graphics.Color.parseColor("#239b56f") //Wrong color format 

色の文字列を解析し、対応する色-int型を返します。文字列を解析できない場合、IllegalArgumentException例外がスローされます。対応フォーマットは以下のとおりです。

RRGGBB

AARRGGBB

使用HEX文字列。

+1

https://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String) –

+1

これがカラーコード#239b56f次に16進コードをどのように達成するか。 – Bunky

+0

@Bunky use '#239b56'。最後の文字を削除する –

0
android.graphics.Color.parseColor("#54D66A") 

Documentation

からの色文字列を解析し、対応する色-INTを返します。文字列を解析できない場合、IllegalArgumentException例外がスローされます。 #RRGGBB #AARRGGBB赤、青、緑、黒、白、灰色、シアン、マゼンタ、 '

color.xmlで色を定義し、色コードがRGBパターンと一致しないためにそこから色を取得します。

.withBackgroundColor(ContextCompat.getColor(this, R.color.your_color); 
関連する問題