0

I made a splash screen with react-native-splash-screen and it works fine now want to rotate an image ( infinite rotation ) I tried this code .. but the app keeps crashing before opens is there any way to achieve this?

res/anim/rotate.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/cycle_interpolator">
    <rotate android:fromDegrees="0"
        android:toDegrees="360"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="5000" />
</set>

res/layout/launch_screen.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#fff">
    <ImageView        
    android:src="@drawable/launch_screen" 
    android:layout_width="fill_parent"
    android:layout_centerVertical="true"
    android:layout_height="140dp" />
    <ImageView
    android:id="@+id/imgvw"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="175dp"
    android:src="@drawable/loading" 
    android:layout_width="fill_parent"
    android:layout_centerVertical="true"
    android:layout_height="80dp" 
    />
    <ImageView        
    android:layout_alignParentBottom="true"
    android:src="@drawable/copyrights" 
    android:layout_width="fill_parent"
    android:layout_marginBottom="30dp"
    android:layout_height="20dp" />

</RelativeLayout> 

mainActivity.java

...other imports/

import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class MainActivity extends ReactActivity {
 @Override
  protected ReactActivityDelegate createReactActivityDelegate() {
  SplashScreen.show(this);
    ImageView img = (ImageView)findViewById(R.id.imgvw);
    //Animation aniRotate = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate);
   // img.startAnimation(aniRotate);

   
    return new MainActivityDelegate(this, getMainComponentName());
  }

...default app code.

}

i got this error :

 java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object
ripouu
  • 93
  • 8
  • Post your stack trace also. – Bhavnik Oct 07 '22 at 14:46
  • I did a try-catch and.. didn't crash... I did print Exception .. but can't find it since I'm using vs code (react native project) – ripouu Oct 07 '22 at 16:59
  • i find the exception : java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference – ripouu Oct 07 '22 at 17:34

0 Answers0