1

I am using a third party library for splash screen. I got it from https://github.com/ViksaaSkool/AwesomeSplash. I have followed the whole tutorial but i am getting error while setting string path. It has a line "configSplash.setPathSplash(SyncStateContract.Constants.DROID_LOGO); //set path String". Android studio is unable to resolve DROID_LOGO and i am getting error. I replaced DROID_LOGO with DATA and got this error. As suggested on the post i have written this code.

public class splashex extends AwesomeSplash {

//DO NOT OVERRIDE onCreate()!
//if you need to start some services do it in initSplash()!


@Override
public void initSplash(ConfigSplash configSplash) {

        /* you don't have to override every property */

    //Customize Circular Reveal
    configSplash.setBackgroundColor(R.color.colorPrimary); //any color you want form colors.xml
    configSplash.setAnimCircularRevealDuration(2000); //int ms
    configSplash.setRevealFlagX(Flags.REVEAL_RIGHT);  //or Flags.REVEAL_LEFT
    configSplash.setRevealFlagY(Flags.REVEAL_BOTTOM); //or Flags.REVEAL_TOP

    //Choose LOGO OR PATH; if you don't provide String value for path it's logo by default

    //Customize Logo
    configSplash.setLogoSplash(R.mipmap.ic_launcher); //or any other drawable
    configSplash.setAnimLogoSplashDuration(2000); //int ms
    configSplash.setAnimLogoSplashTechnique(Techniques.Bounce); //choose one form Techniques (ref: https://github.com/daimajia/AndroidViewAnimations)


    //Customize Path
    configSplash.setPathSplash(SyncStateContract.Constants.DROID_LOGO); //set path String(**I am getting error here**)
    //     configSplash.setOriginalHeight(400); //in relation to your svg (path) resource
    configSplash.setOriginalWidth(400); //in relation to your svg (path) resource
    configSplash.setAnimPathStrokeDrawingDuration(3000);
    configSplash.setPathSplashStrokeSize(3); //I advise value be <5
    configSplash.setPathSplashStrokeColor(R.color.colorPrimaryDark); //any color you want form colors.xml
    configSplash.setAnimPathFillingDuration(3000);
    configSplash.setPathSplashFillColor(R.color.colorPrimaryDark); //path object filling color


    //Customize Title
    configSplash.setTitleSplash("My Awesome App");
    configSplash.setTitleTextColor(R.color.colorAccent);
    configSplash.setTitleTextSize(30f); //float value
    configSplash.setAnimTitleDuration(3000);
    configSplash.setAnimTitleTechnique(Techniques.FlipInX);
    configSplash.setTitleFont("fonts/myfont.ttf"); //provide string to your font located in assets/fonts/

}

@Override
public void animationsFinished() {

    //transit to another activity here
    //or do whatever you want
}

}

The error i am getting is

  java.lang.RuntimeException: Font asset not found fonts/myfont.ttf
  at android.graphics.Typeface.createFromAsset(Typeface.java:190)

I searched various links and all suggested to add assets folder but i dont know where to make assets folder and what to store in that. please help me with all the details about assets and fonts.

Still i am getting this.

added the font folder still i am getting the same error.

3 Answers3

1

You have to create folder named fonts according to the following path:

your_android_project_folder > app > src > main > assets > fonts

Now within your fonts folder,you need to store your myfont.ttf file.

enter image description here

Ayan
  • 8,192
  • 4
  • 46
  • 51
  • I can see image asset and vector asset in the options.Which should i choose.? – Android enthusiast Oct 03 '16 at 08:31
  • @Vipin You will also find a option to create directory in there.Just create a directory named fonts. – Ayan Oct 03 '16 at 09:09
  • Done. But since i am using third party library i don't have myfonts.ttf. May you guide me as how can i get that.? – Android enthusiast Oct 03 '16 at 09:15
  • Check this : https://github.com/ViksaaSkool/AwesomeSplash/tree/master/app/src/main/assets/fonts . You can copy any of the .ttf files to your fonts folder,and use that particular font file in your code. – Ayan Oct 03 '16 at 09:17
  • I had tried this but of no use. If i use diti_sweet.ttf from there what should i use to replace DROID_LOGO. Since this ttf file is not opening. – Android enthusiast Oct 03 '16 at 10:17
  • What is the splashx.java class for? What error are you specificially getting when trying to use the font file?Did you check with other font files? – Ayan Oct 03 '16 at 10:51
  • DROID_LOGO is not getting resolved. I pasted all the fonts file still the DROID_LOGO is showing errors. I don't have any idea what kind of string DROID_LOGO is. – Android enthusiast Oct 03 '16 at 11:19
  • click on "Constatnts" in the line : configSplash.setPathSplash(SyncStateContract.Constants.DROID_LOGO); and type Ctrl+B .It will take you to the file where Contants is declared.Then you need to create DROID_LOGO in there – Ayan Oct 03 '16 at 11:28
  • 2
    Check the DROID_LOGO in here : https://github.com/ViksaaSkool/AwesomeSplash/blob/master/app/src/main/java/com/viksaa/ssspalsh/util/Constants.java . This DROID_LOGO can't be recognized for some reason.Try to clean and rebuild your project. – Ayan Oct 03 '16 at 11:31
  • 1
    It worked. I created Constants class and wrote the same code and it worked. Thanks man. Since i have very less points my upvote won't count. Still upvoting. – Android enthusiast Oct 03 '16 at 12:35
  • No problem.Thanks. – Ayan Oct 03 '16 at 15:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/124842/discussion-between-vipin-and-ayan). – Android enthusiast Oct 04 '16 at 04:39
0

I had the same problem and here is how I solved it :

  1. For the missing DROID_LOGO, you can rewrite the line from this:

    configSplash.setPathSplash(SyncStateContract.Constants.DROID_LOGO);

to this :

configSplash.setPathSplash(SyncStateContract.Constants.DROID_LOGO);

Here, make sure you add to your project the Constants.java class which can be found here

  1. And for the missing font, go to the line

    configSplash.setTitleFont("fonts/myfont.ttf"); //provide string to your font located in assets/fonts/

and replace myfont.ttf with another font present in your assets/font folder for example fonts/diti_sweet.ttf(which can be found on the AwesomeSplash repository) and averything might work fine

0

Comment out this line:

configSplash.setPathSplash(SyncStateContract.Constants.DROID_LOGO);

and rename myfont.ttf to your font in folder assets.

Simson
  • 3,373
  • 2
  • 24
  • 38