Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Flutter and app store releases

Android build cannot find ExoPlayer's DefaultHttpDataSourceFactory class

Your error

error: cannot find symbol1 more line it can show

Fix it fast

Most common cause, 1 of 2

The app is on ExoPlayer 2.16 or later, where the old factory was deleted

Swap the old constructor for the nested Factory class in the same package.

Fix
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;

DataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory();
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

error: cannot find symbol DefaultHttpDataSourceFactory appears because ExoPlayer 2.16.0 removed that class; DefaultHttpDataSource.Factory replaced it. If the project already depends on AndroidX Media3, every com.google.android.exoplayer2 import fails too, since ExoPlayer moved to androidx.media3 and 2.19.1 was its last release. Use the Factory class, and migrate old imports to Media3 1.11.

  • Applies to AndroidX Media3 1.11.1, ExoPlayer 2.16.0 to 2.19.1 (last release), Android Gradle plugin 9.5
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Find out which player library the build actually pulls in. com.google.android.exoplayer2 entries point to cause 1; androidx.media3 entries point to cause 2.

Run this first
grep -rnE "exoplayer|media3" --include=*.gradle --include=*.kts --include=*.toml .

Then find the line you see in this list and open its fix:

  1. 1The app is on ExoPlayer 2.16 or later, where the old factory was deletedGradle lists com.google.android.exoplayer2 at 2.16.0 or higher, and only DefaultHttpDataSourceFactory fails while other exoplayer2 imports compile
  2. 2The project depends on AndroidX Media3, but the code still uses ExoPlayer 2 packagesGradle lists androidx.media3 artifacts, and every import starting with com.google.android.exoplayer2 is unresolved

What does the error look like?

  • error: cannot find symbol
  • import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;

Cause 1 of 2

The app is on ExoPlayer 2.16 or later, where the old factory was deleted

You seeGradle lists com.google.android.exoplayer2 at 2.16.0 or higher, and only DefaultHttpDataSourceFactory fails while other exoplayer2 imports compile

Check

ExoPlayer's release notes show the cannot-find-symbol class history: 2.13.0 added DefaultHttpDataSource.Factory and deprecated DefaultHttpDataSourceFactory, and 2.16.0 removed the old class. Samples written before 2.13.0 (February 2021) still call the old name.

Check
grep -rn "DefaultHttpDataSourceFactory" app/src

Fix

Swap the old constructor for the nested Factory class in the same package. It is a drop-in DataSource.Factory, so the media source code that receives it stays the same.

Fix
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;

DataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory();

Verify

The project compiles and the stream plays with the new factory.

Verify
./gradlew assembleDebug

Confirmed by github.com

Did this fix it?

Cause 2 of 2

The project depends on AndroidX Media3, but the code still uses ExoPlayer 2 packages

You seeGradle lists androidx.media3 artifacts, and every import starting with com.google.android.exoplayer2 is unresolved

Check

The old ExoPlayer repository is deprecated and 2.19.1 was its last artifact; new releases ship only as AndroidX Media3 under androidx.media3 packages. Code copied from an ExoPlayer 2 sample cannot find any of its classes against Media3.

Check
grep -rln "com.google.android.exoplayer2" app/src | head

Fix

Run Google's migration script, which rewrites Gradle files, Java, Kotlin and XML from 2.19.1 to Media3, or change the imports by hand. The HTTP factory lives in androidx.media3.datasource. Media3 marks many of its setters @UnstableApi, which needs an @OptIn annotation to clear the lint error.

Fix
curl -o media3-migration.sh "https://raw.githubusercontent.com/google/ExoPlayer/r2.19.1/media3-migration.sh"
chmod 744 media3-migration.sh
./media3-migration.sh -l -f /path/to/gradle/project/root
./media3-migration.sh -m /path/to/gradle/project/root

// after migration, for an HLS (.m3u8) stream
DataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory();
HlsMediaSource hlsMediaSource =
    new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(hlsUri));

Verify

A clean build succeeds and Android Studio shows androidx.media3 imports only.

Verify
./gradlew clean build

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Keep all player artifacts on one version, declared once in the version catalog (libs.versions.toml).
  • Before copying a player sample, check that its imports start with androidx.media3; ExoPlayer 2 code no longer gets updates.
  • Fix struck-through deprecated calls when they first appear, before the next major version deletes them.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: QistLock, Nuclear Home Video.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.