Hot questions for Using Lottie in android

Question:

I was getting started with Lottie when I came across this error. I added the dependency to my build.gradle

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'org.jsoup:jsoup:1.11.2'
implementation 'com.airbnb.android:lottie:2.8.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha06'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha06'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

Since I added implementation 'com.airbnb.android:lottie:2.8.0' build succeeds but I cant run my application as there is an error in the Manifest Merging.

Merging Errors: Error: Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from AndroidManifest.xml:22:18-86 is also present at AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:14:5-35:19 to override. app main manifest (this file), line 21 

Here is my Manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.rishav.sanfoundryfer">

    <dist:module dist:instant="true" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:logo="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="GoogleAppIndexingWarning">
        <activity android:name=".QuestionActivity"
            android:label="MCQs"/>
        <activity android:name=".TopicActivity"
            android:label="Select Topic"/>
        <activity android:name=".SubjectActivity"
            android:label="Select Subject"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Answer:

The fact that the error has androidx.core.app.CoreComponentFactory points to the fact that the new "Jetpack" support library packages are being used. Seeing that your manifest uses the "older" packages points to the fact that it probably is used by lottie. You can make sure that this is the reason by inspecting the library. To resolve the issue you can use an older lottie library, start using the jetpack support library packages or resolve the merge manually. You can take a look at the merged manifest if you navigate to the AndroidManifest.xml and switch to the Merged Manifest tab at the bottom of the window.

Question:

im using a Lottie Library to give some animation to my app. Im testing a simple loading example with a DialogFragment, but the background color of dialog is white and im need that color to be invisible.

Activity:

public class MainActivity extends AppCompatActivity implements MainActivityContract.View{

private ProgressDialog progressDialog;
private Button button;
private MainActivityContract.Presenter presenter;

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

    button = findViewById(R.id.button);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {


        }
    });

    presenter = new MainActivityController(this);
    presenter.initInterface();
}

@Override
public void initProgressBar() {
    progressDialog = new ProgressDialog();
    progressDialog.show(getSupportFragmentManager(),"teste");
}

@Override
public void finishProgressBar() {
    progressDialog.dismiss();
}
}

Layout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/invisible"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.airbnb.lottie.LottieAnimationView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:lottie_autoPlay="true"
    app:lottie_rawRes="@raw/glow_loading"
    app:lottie_loop="true"/>

</FrameLayout>

and that is my background color:

<color name="invisible">#00ffffff</color>

Thx!


Answer:

I fix the problem with onActivityCreated code.

public class ProgressDialog extends DialogFragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.progress_bar, container);

    return rootView;
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme);
}
}